, - - , ORDER BY.
, script, . (SQL 2008 Dev) script. 2 . , , , ( - ), . .
:
ID D1 V1
----------- ----------------------- ----------------------------------------------------------------------------------------------------
32 2010-03-01 00:00:00.000 text
60 2010-02-01 00:00:00.000 text
(2 row(s) affected)
ID D1 V1
----------- ----------------------- ----------------------------------------------------------------------------------------------------
60 2010-03-01 00:00:00.000 text
32 2010-02-01 00:00:00.000 text
(2 row(s) affected)
script, :
create table T1 (
ID int not null,
D1 datetime not null,
V1 varchar(100) not null,
constraint PK_T1 PRIMARY KEY (D1,ID)
)
go
create index IX_T1_D1 on T1(D1)
go
insert into T1(ID,D1,V1)
select ID,DATEADD(day,ID-1,'20100101'),'text'
from (select ROW_NUMBER() OVER (ORDER BY so1.id) from sysobjects so1,sysobjects so2,sysobjects) t(ID)
go
create trigger T_T1_U on T1 after update
as
begin
select * from inserted
select * from deleted
end
go
sp_configure 'disallow results from triggers',0
go
RECONFIGURE
go
update T1 set D1 = DATEADD(month,CASE WHEN DATEPART(month,D1)=2 THEN 1 ELSE -1 END,D1)
where D1 in ('20100201','20100301')
go
sp_configure 'disallow results from triggers',1
go
RECONFIGURE
go
drop table T1
go