--这样试一下 Declare @t Table(Rq Datetime) Insert @t Select '2006-07-26' Union all Select '2006-07-26' Union all Select '2006-07-23' --Try Update @t Set Rq=DateAdd(day,2,Rq) Where DateDiff(day,Rq,'2006-7-26')=0 -- Select * From @t
Declare @t Table(Rq Datetime) Insert @t Select '2006-07-26' Union all Select '2006-07-26' Union all Select '2006-07-23' --Try Update @t Set Rq='2006-7-28 'Where rq='2006-7-26' -- Select * From @t
Declare @t Table(Rq Datetime) Insert @t Select '2006-07-26' Union all Select '2006-07-26' Union all Select '2006-07-23' --Try Update @t Set Rq=DateAdd(day,2,Rq) --Where DateDiff(day,Rq,'2006-7-26')=0 --改为 where rq='2006-7-26' --这样可以用上索引
Declare @t Table(Rq Datetime)
Insert @t Select '2006-07-26'
Union all Select '2006-07-26'
Union all Select '2006-07-23'
--Try
Update @t
Set Rq=DateAdd(day,2,Rq)
Where DateDiff(day,Rq,'2006-7-26')=0
--
Select * From @t
Insert @t Select '2006-07-26'
Union all Select '2006-07-26'
Union all Select '2006-07-23'
--Try
Update @t
Set Rq='2006-7-28 'Where rq='2006-7-26'
--
Select * From @t
Insert @t Select '2006-07-26'
Union all Select '2006-07-26'
Union all Select '2006-07-23'
--Try
Update @t
Set Rq=DateAdd(day,2,Rq)
--Where DateDiff(day,Rq,'2006-7-26')=0
--改为
where rq='2006-7-26' --这样可以用上索引
我还以为可以直接用Update进行修改就行了呢!
原来还得这么复杂。
谢谢各位大虾了!
set rq='20060728' where rq='20060726'这样写有问题吗?
update TA
set rq = replace('2006-07-26','26','28')