if object_id('[tb]') is not null drop table [tb] go create table [tb]([col1] varchar(3),[col2] int) insert [tb] select 'aaa',2 union all select 'bbb',3select col1,1 as col2 from tb a join master..spt_values b on b.type='P' and a.col2>b.number /** col1 col2 ---- ----------- aaa 1 aaa 1 bbb 1 bbb 1 bbb 1(5 行受影响) **/
go
create table [tb]([col1] varchar(3),[col2] int)
insert [tb]
select 'aaa',2 union all
select 'bbb',3select col1,1 as col2 from tb a
join master..spt_values b on b.type='P' and a.col2>b.number
/**
col1 col2
---- -----------
aaa 1
aaa 1
bbb 1
bbb 1
bbb 1(5 行受影响)
**/