日期:2014-05-18  浏览次数:20650 次

跪求答案:求一条update语句
You   need   to   modify   the   information   of   the   columns   of   CompanyName   and   ContactName.   The   data   are   required   to   be   different   for   each   record.   For   example,   the   company   name   is   Company1   for   the   first   record,   Company2   for   the   second   record,   Company3   for   the   third   record,   and   so   on.  

大侠帮忙啊!

------解决方案--------------------
declare @t table(CompanyName varchar(100))
insert @t select 'CompanyName3 '
union all select 'CompanyName8 '
union all select 'CompanyName11 '
union all select 'CompanyName98 '
union all select 'CompanyName56 '
union all select 'CompanyName3 '
union all select 'CompanyName7 '
union all select 'CompanyName1 '

select * from @t

declare @i int
set @i=0
update @t set CompanyName= 'CompanyName '+cast(@i as varchar),@i=@i+1

select * from @t