34,590
社区成员
发帖
与我相关
我的任务
分享
declare @table table(a1 varchar(20),a2 varchar(10))
insert into @table
select 'AA01',1 union all
select 'AA01',2 union all
select 'AA01',3 union all
select 'AA02',1 union all
select 'AA02',1 union all
select 'AA03',1 union all
select 'AA03',2 union all
select 'AA03',3
declare @i int
set @i=0
update @table set a2=@i,@i=@i+1 where a1='AA02'
select * from @table
delete @table where a1='AA02' and a2=2
select * from @table
/*
(8 行受影响)
(2 行受影响)
a1 a2
-------------------- ----------
AA01 1
AA01 2
AA01 3
AA02 1
AA02 2
AA03 1
AA03 2
AA03 3
(8 行受影响)
(1 行受影响)
a1 a2
-------------------- ----------
AA01 1
AA01 2
AA01 3
AA02 1
AA03 1
AA03 2
AA03 3
(7 行受影响)
*/
declare @table table(a1 varchar(20),a2 varchar(10))
insert into @table
select 'AA01','1' union all
select 'AA01','2' union all
select 'AA01','3' union all
select 'AA02','1' union all
select 'AA02','1 *' union all
select 'AA03','1' union all
select 'AA03','2' union all
select 'AA03','3'
SELECT a1+a2,* FROM @table WHERE ISNUMERIC(a2)=1
------------result:
/*
AA011 AA01 1
AA012 AA01 2
AA013 AA01 3
AA021 AA02 1
AA031 AA03 1
AA032 AA03 2
AA033 AA03 3
*/