易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL替换指定列字符串

 -- ================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE replaceStr
-- Add the parameters for the stored procedure here
@keywords varchar(max),@afterwords varchar(max)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @word varchar(max);
declare @rowcount int;
declare @count int;
set @count = 1;
-- Insert statements for procedure here
begin try
begin tran replaceStr
select @rowcount = count(*) from Logfile;
while @count <= @rowcount
begin
select @word = lcontent from Logfile where lid = @count; --lcontent列名,Logfile表名,lid自增长主键
update Logfile set lcontent = replace(@word,@keywords,@afterwords) where lid = @count;
set @count = @count + 1;
end
commit tran
end try
begin catch
rollback tran
end catch
END
GO


相关文档:

SQL Server2005 Synonym的使用

--> Title  : SQL Server2005 Synonym的使用
--> Author : wufeng4552
--> Date   : 2009-10-30
1.Synonym的概念
   Synonym(同义词)是SQL Server 2005的新特性。可以简单的理解Synonym为其他對象的别名。
語法
CREATE SYNONYM [ schema_name_1. ] synonym_name FOR & ......

sql server一个使用游标的实例

--创建游标
DECLARE Cursor1 CURSOR FOR
SELECT NODE_NO,NODE_VALUE,SUM(RESALE_SUM-RESALERETU_SUM+SALE_SUM-SALERETU_SUM) sale_sum,
SUM(STORE_SUM) sum_store,SUM(STORE_SUM) store_sum,
sum(RESALE_PROFIT-RESALERETU_PROFIT+SALE_PROFIT-SALERETU_PROFIT-ADJUST_PROFIT) sale_profit
from ......

SQL中DATEADD和DATEDIFF的用法

固定日期减一个月(日、年)
dateadd(表达式1,表达式2,表达式3)
表达式1为MM或YY或DD
表达式2为1
表达式3为要减的日期 一个月的第一天 第一个例子,我将告诉你如何从当前日期去这个月的最后一天。请注意:这个例子以及这篇文章中的其他例子都将只使用DATEDIFF和DATEADD函数来计算我们想要的日 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号