易截截图软件、单文件、免安装、纯绿色、仅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故障转移群集的时候应该选择哪种模式?

如果我们的SQL Server要保证高可用性,那么可以采用故障转移群集。最简单的故障转移群集是两台服务器,一台做活动的服务器,另一台做备用服务器,这就是AP模式的Cluster。另外一个模式就是AA模式,也就是两台服务器都是运行SQL Server实例。
SQL Server不像Oracle一样有RAC,所以不可能说两台服务器同时运行同一个实例,想 ......

避免SQL注入和特殊字符的一种方法

 递归小谈自备C#辅助函数
十08
避免SQL注入和特殊字符的一种方法
C#Add comments
避免SQL注入和特殊字符的办法有很多,不同数据库也有不同数据库的解决方案,ADO.NET中使用DbCommand.Parameters解决这个问题,为了了解他的原理,我查了一下.NET中SQLCommand的源代码和MySQL.NET中MySQLCommand的源代码。
.NET源代 ......

防止SQL注入

一、使用参数化输入。存储过程里尽量避免语句拼接。
二、对于一些数据库,必须设置权限,甚至设置到字段。
三、始终通过测试类型、长度、格式和范围来验证用户输入。
四、过滤敏感字符。
Function ReplaceStr(Str)
Str=Trim(Str)
Str=Replace(Str,"'","'")
Str=Replace(Str,";",";")
Str=Rep ......

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 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号