日期:2014-05-17 浏览次数:20500 次
USE test
GO
-->生成表tb
if object_id('tb') is not null
drop table tb
Go
Create table tb([A] nvarchar(2),[B] nvarchar(2),[C] smallint)
Insert into tb
Select N'AA',N'BB',3
UNION ALL Select N'aa',N'bb',4 -- test
select
a.A
,REPLICATE(NCHAR(UNICODE(a.B)+b.number),LEN(a.B)) AS B
,1 AS C
from
tb AS a
,master.dbo.spt_values AS b
WHERE b.type='p'
AND b.number BETWEEN 1 AND a.C
/*
A B C
---- ---- ---
AA CC 1
AA DD 1
AA EE 1
aa cc 1
aa dd 1
aa ee 1
aa ff 1
*/