34,593
社区成员
发帖
与我相关
我的任务
分享
create table tb(ar varchar(5),ak varchar(10),cn int)
insert into tb
select '11','SHT009T',5
go
select right(10000 + cast(a.ar as int)+ b.number,2),a.ak
from tb a,master..spt_values b
where b.type = 'p' and b.number < a.cn
drop table tb
ak
---- ----------
11 SHT009T
12 SHT009T
13 SHT009T
14 SHT009T
15 SHT009T
(5 行受影响)
create table tb(ar varchar(5),ak varchar(10),cn int)
insert into tb
select '01','SHT009T',5
go
select right(10000+b.number,2),a.ak
from tb a,master..spt_values b
where b.type = 'p' and b.number < a.cn
drop table tb
ak
---- ----------
00 SHT009T
01 SHT009T
02 SHT009T
03 SHT009T
04 SHT009T
(5 行受影响)
create table tb(id char(10),styleid char(20),lix int)
insert into tb
select '01','SHT009T',5
select '0'+rtrim(a.number+1) as id ,b.styleid
from master..spt_values a,tb b
where type='p' and a.number<b.lix
/*
id styleid
------------- --------------------
01 SHT009T
02 SHT009T
03 SHT009T
04 SHT009T
05 SHT009T
select b.id,b.styleid,'0'+ltrim(a.number+1)
from master..spt_values a,tb b
where type='P' and a.number<b.lix
create table tb(id char(10),styleid char(20),lix int)
insert into tb
select '01','SHT009T',5
select b.id,b.styleid
from master..spt_values a,tb b
where type='p' and a.number<b.lix
/*
id styleid
---------- --------------------
01 SHT009T
01 SHT009T
01 SHT009T
01 SHT009T
01 SHT009T