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
相关文档:
一、使用参数化输入。存储过程里尽量避免语句拼接。
二、对于一些数据库,必须设置权限,甚至设置到字段。
三、始终通过测试类型、长度、格式和范围来验证用户输入。
四、过滤敏感字符。
Function ReplaceStr(Str)
Str=Trim(Str)
Str=Replace(Str,"'","'")
Str=Replace(Str,";",";")
Str=Rep ......
--> 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 & ......
这是一个CSDN Oracle开发版块里,网友问过的一道题
题如下
create table A_TEST
(
PAYOUT_ITEM_CODE VARCHAR2(30) not
null,
FORMULA_DET VARCHAR2(1000)
)
create table B_TEST
(
ELEMENT_ID VARCHAR2(5) not null,
NAME VARCHAR2(41)
)
求写oracle多个字符替换(有测试数据)
inser ......
SUBSTRING
返回字符、binary、text 或 image 表达式的一部分。有关可与该函数一起使用的有效 Microsoft® 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 ......