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 #
相关文档:
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语句,本文假定已经建立了一个学生成绩管理数据库,全文均以学生成绩的管理为例来描述。
1.在查询结果中显示列名:
a.用as关键字:select name as '姓名' from students order by age
b.直接表示:select name '姓名' from students order by age
2.精确查找:
a.用 ......
sql在多方摸索和朋友的帮助下,终于可以连接成功,这对我来说是个里程碑来的,在工作的过程中我总是没有机会可以碰触到SQL,当我鼓起勇气勇气想学习的时候我连怎么用都不会,进来终于链接成功,开心地和朋友分享我的成果。
1.安装sql,学习SQl,因为一般我是想要用于VS2005项目的,所以一般最后就先安装VS软件,以便 ......