Snowfun

导航

 

 create table #test01(c1 int identity(1,1) ,c2 nvarchar(2000))

 

--篩選數據後放入表01

insert into #test01

select  'sp_addlogin ' + '''' + rtrim(ltrim(usrname)) + ''', ' + '''' + rtrim(ltrim(usrname))  + ''''     from maxusergroups

 

--查詢表01的行數再添加字段go

select c1,c2='go'   into #test02   from #test01

 

--創建新表03

create table #test03(c1 int ,c2 nvarchar(2000))

 

--將表01和表02的數據插入到表03

insert into #test03   select * from #test01

insert into #test03   select * from #test02

 

select * from #test01 order by c1,c2

select * from #test02 order by c1,c2

select * from #test03 order by c1,c2  --最終結果

 

posted on 2010-09-27 08:12  Snowfun  阅读(1396)  评论(0编辑  收藏  举报