原文地址:http://www.cnblogs.com/zerocc/archive/2011/11/28/2266180.html SQL中 WITH AS 的用法和注意事项 1.为什么使用with as 我们在使用sql语句的时候经常使用子查询,但是子查询占用系统的资源是很多了,如果用在了循环中更是可怕,当然我们可以使用表量函数,但是标量函数的成本还是否不小,所以sql2005给我们提供了一个表达式 with as 使用with as应该注意 1 with as后面必须紧跟使用CTE(Com
update 表名 set 字段名=replace(cast(与前面一样的字段名 as varchar(8000)) ,'原本内容','想要替换成什么') update News set news_detail=replace(cast(news_detail as varchar(8000)) ,'http://tengxin.hotcenkj.com','http://m.gzfx88.com')
select * ,replace(NewsContent,'src=','修改后的内容') as rep from News where id=337update News set NewsContent=replace(cast(NewsContent as varchar(max)),'src="','src="http:') where id=(select NewsTitle,NewsContent from news where ID='337')
UPDATE dede_archives SET writer='你需要修改的作者' WHERE writer=''; UPDATE dede_archives SET source='你需要修改的来源' WHERE source=''; 如果你要把全部的来源和作者修改为统一的来源和作者,只需要把后面的where条件去掉,即: UPDATE dede_archives SET writer='你需要修改的作者' UPDATE dede_archives SET source='你需要修改的来源'
实用的SQL语句 行列互转 create table test(id int,name varchar(20),quarter int,profile int) insert into test values(1,'a',1,1000)insert into test values(1,'a',2,2000)insert into test values(1,'a',3,4000)insert into test values(1,'a',4,5000)insert into test va
行列互转 ) select * from test2 --列转行 select id,name,quarter,profile from test2 unpivot ( profile for quarter in ([Q1],[Q2],[Q3],[Q4]) ) as unpvt sql替换字符串 substring replace SQL查询一个表内相同纪录 having 如果一个ID可以区分的话,可以这么写 ) 如果几个ID才能区分的话,可以这么写 其他回答:数据表是zy_bho,想找
行列互转 复制代码 create table test(id ),quarter int,profile int) insert into test values(,,) insert into test values(,,) insert into test values(,,) insert into test values(,,) insert into test values(,,) insert into test values(,,) insert into test values(