首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

跪求答案:求一条update语句解决方案

2012-01-26 
跪求答案:求一条update语句YouneedtomodifytheinformationofthecolumnsofCompanyNameandContactName.Theda

跪求答案:求一条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

热点排行