日期:2014-05-17 浏览次数:20539 次
create table #tb( AutoNum int identity, Same int ) insert #tb (Same)select 1 declare @a int set @a=1 while @a<=10 begin insert #tb select @@identity+1 set @a=@a+1 end select * from #tb /* AutoNum Same 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 */
------解决方案--------------------
create table #ttt( AutoNum int identity, Same as AutoNum, value char(1) ) insert #ttt(value) select 'a' union all select 'b' union all select 'c' union all select 'd' union all select 'e' union all select 'f' select * from #ttt /* AutoNum Same value 1 1 a 2 2 b 3 3 c 4 4 d 5 5 e 6 6 f */ --如果还有别的字段
------解决方案--------------------
insert info(name,sex)
select '张三','男' union all
select '李四',‘女’
------解决方案--------------------
Create Trigger UpdateSname On info After Update As Update info Set same=id FROM info a,inserted b WHERE a.AutoNum = b.AutoNum