读书人

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

发布时间: 2012-01-26 19:40:46 作者: rapoo

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

读书人网 >SQL Server

热点推荐