MSSQL2005常用的數(shù)據(jù)庫(kù)操作SQL語(yǔ)句:
批量替換標(biāo)題或描述里的字符串
update 表名 set 要替換的字段=replace(要替換的字段,'要替換的字符','替換的字符')
如update products set title=replace(title,'szfangwei.net','www.szfangwei.net')
如果要替換的字段不是nvarchar或varchar,需要轉(zhuǎn)換,
update 表名 set 要替換的字段=replace(CAST(要替換的字段 as varchar(8000)),'要替換的字符','替換的字符')
如:update products set description=replace(CAST(description AS varchar(8000)),'Swarovski','Swarovski Elements') where description like '%Swarovski%'
當(dāng)然也可以用于批量替換產(chǎn)品價(jià)格等
如下:
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)
如沒(méi)特殊注明,文章均為方維網(wǎng)絡(luò)原創(chuàng),轉(zhuǎn)載請(qǐng)注明來(lái)自http://pdcharm.com/news/1666.html