读书人

请帮忙解决以下更新有关问题!偶想了三

发布时间: 2012-01-12 22:11:58 作者: rapoo

请帮忙解决以下更新问题!!!偶想了三天半没解决~

zd1

C

C

C

如果要在zd1后面加上数字,要怎么写语句?(C1,C2,C3...C12,c13...c20,c21)

请注释以下语句的意思:(有能修复表 'sysindexes '一致性错误的语句吗?)
exec sp_msforeachtable 'DBCC CHECKTABLE( ' '? ' ',REPAIR_REBUILD) '
exec sp_msforeachtable 'DBCC DBREINDEX( ' '? ' ') '

[解决办法]
select id=identity(int,1,1) , * into test from tb

select zd1 + cast(id as varchar) from test
[解决办法]
declare @t table(CODE varchar(8))
insert into @t select 'C '
insert into @t select 'C '
insert into @t select 'C '
insert into @t select 'C '
insert into @t select 'C '
insert into @t select 'C '
insert into @t select 'C '
insert into @t select 'C '

declare @i int
set @i=0

update @t set @i=@i+1,CODE=CODE+rtrim(@i)

select * from @t

/*
CODE
--------
C1
C2
C3
C4
C5
C6
C7
C8
*/

读书人网 >SQL Server

热点推荐