当前位置: 代码迷 >> Sql Server >> 请帮忙解决以下更新有关问题!偶想了三天半没解决
  详细解决方案

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

热度:50   发布时间:2016-04-27 15:49:55.0
请帮忙解决以下更新问题!!!偶想了三天半没解决~

                                                    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 @[email protected]+1,CODE=CODE+rtrim(@i)

select * from @t

/*
CODE
--------
C1
C2
C3
C4
C5
C6
C7
C8
*/
  相关解决方案