declare @t table (id varchar(18)) insert into @t select '6227228001011011' union all select '622722199001011011' union all select '622722198801011011' union all select '622722890101101' -- select siteID=identity(int,1,1),id into # from @tselect * from #drop table #
declare @t table (id varchar(18)) insert into @t select '6227228001011011' union all select '622722199001011011' union all select '622722198801011011' union all select '622722890101101' -- select siteID=identity(int,1,1),id into # from @t --------------------------------------------------- 注意这个地方虽然是插入,但是是插入的一个临时表select * from # --------------------------------------------------这里显示临时表内容,drop table # -------------------------- 这里把临时表又删掉了所以,其实显示的时候你看到的就是加了序号的结果而已。
insert into @t select '6227228001011011'
union all select '622722199001011011'
union all select '622722198801011011'
union all select '622722890101101'
--
select siteID=identity(int,1,1),id into # from @tselect * from #drop table #
在2005里面有个row_number()函数可以实现你要的功能!
insert into @t select '6227228001011011'
union all select '622722199001011011'
union all select '622722198801011011'
union all select '622722890101101'
--
select siteID=identity(int,1,1),id into # from @t
---------------------------------------------------
注意这个地方虽然是插入,但是是插入的一个临时表select * from #
--------------------------------------------------这里显示临时表内容,drop table #
--------------------------
这里把临时表又删掉了所以,其实显示的时候你看到的就是加了序号的结果而已。
参看onlinebook