MSSQL2005常用的数据库操作SQL语句:
批量替换标题或描述里的字符串
update 表名 set 要替换的字段=replace(要替换的字段,'要替换的字符','替换的字符')
如update products set title=replace(title,'szfangwei.net','www.szfangwei.net')
如果要替换的字段不是nvarchar或varchar,需要转换,
update 表名 set 要替换的字段=replace(CAST(要替换的字段 as varchar(8000)),'要替换的字符','替换的字符')
如:update products set description=replace(CAST(description AS varchar(8000)),'Swarovski','Swarovski Elements') where description like '%Swarovski%'
当然也可以用于批量替换产品价格等
如下:
update products set price=price*5 where categoryid=5
update products set price=price*2 where categoryid in(91,92,93,94,96,97,98,99,56,166,170,168,169,167,171,172,174,175,176,177,82,100,102,103,180,181,182,183)
update products set price=price*4 where categoryid not in(5,91,92,93,94,96,97,98,99,56,166,170,168,169,167,171,172,174,175,176,177,82,100,102,103,180,181,182,183,185)
如没特殊注明,文章均为方维网络原创,转载请注明来自https://www.szfangwei.cn/news/1666.html