MSSQL2005常用的数据库操作SQL语句:
批量替换标题或描述里的字符串
update表名set要替换的字段=replace(要替换的字段,'要替换的字符','替换的字符')
如updateproductssettitle=replace(title,'.net','www..net')
如果要替换的字段不是nvarchar或varchar,需要转换,
update表名set要替换的字段=replace(CAST(要替换的字段asvarchar(8000)),'要替换的字符','替换的字符')
如:updateproductssetdescription=replace(CAST(descriptionASvarchar(8000)),'Swarovski','SwarovskiElements')wheredescriptionlike'%Swarovski%'
当然也可以用于批量替换产品价格等
如下:
updateproductssetprice=price*5wherecategoryid=5
updateproductssetprice=price*2wherecategoryidin(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)
updateproductssetprice=price*4wherecategoryidnotin(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)