SQL Server TEXT类型字段字符串替换示例处理脚本
/*--text字段的替换处理
--*/
--创建数据测试环境
--create table #tb(aa text)
declare @s_str varchar(8000),@d_str varchar(8000), --定义替换的字符串
@p varbinary(16),@postion int,@rplen int,@i_Start int, @i_End int
select identity(int,1,1) as [id],newsid into # from news
select @i_Start=min([id]),@i_End=max([id]) from #
while (@i_Start<=@i_End)
begin
--insert into #tb(aa) select content from # where [id]=@i_Start
select @s_str='\' --要替换的字符串
,@d_str='!' --替换成的字符串
--字符串替换处理
select @p=textptr(content),@rplen=len(@s_str),@postion=charindex(@s_str,content)-1 from news where newsid in (select top 1 newsid from # where [id]=@i_Start)
while @postion>0
begin
updatetext news.content @p @postion @rplen @d_str
select @postion=charindex(@s_str,content)-1 from news where newsid in (select top 1 newsid from # where [id]=@i_Start)
end
--truncate table #tb
select @i_Start=@i_Start+1
end
--删除数据测试环境
--drop table #tb
drop table #
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
and exists (select * from sysobjects) //判断是否是MSSQL and exists(select * from tableName) //判断某表是否存在..tableName为表名 and 1=(select @@VERSION) //MSSQL版本 And 1=(select db_name()) //当前数据库名 and 1=(select @@servername) //本地服务名 and 1=(select IS_SRVROLEMEMBER('sysadmin')) ......
sql在多方摸索和朋友的帮助下,终于可以连接成功,这对我来说是个里程碑来的,在工作的过程中我总是没有机会可以碰触到SQL,当我鼓起勇气勇气想学习的时候我连怎么用都不会,进来终于链接成功,开心地和朋友分享我的成果。
1.安装sql,学习SQl,因为一般我是想要用于VS2005项目的,所以一般最后就先安装VS软件,以便 ......
IIS Web服务器安全加固步骤:
步骤 安装和配置 Windows Server 2003。
注意:
1.将\System32\cmd.exe转移到其他目录或更名;
2.系统帐号尽量少,更改默认帐户名(如Administrator)和描述,密码尽量复杂;
3.拒绝通过网络访问该计算机(匿名登录;内置管理员帐户;Support_388945a0;Guest;所有非操作系统服 ......