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

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

                                                    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
*/