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

高分求答案
use   master

declare   @database   sysname
declare   cursor_name   cursor   fast_forward   read_only   for  
select   [name]   from   sysdatabases   where   dbid> 6

open   cursor_name

FETCH   NEXT   FROM   cursor_name
INTO   @database

WHILE   @@FETCH_STATUS   =   0
BEGIN
execute( 'if   exists(select   *   from   '+@database+ '..syscolumns   where   name= ' 'logtext ' '   and   id=object_id( ' ' '+@database+ '..logregister ' '))
begin
if   not   exists(select   *   from   '+@database+ '..syscolumns   where   name= ' 'logtext_new ' '   and   id=object_id( ' ' '+@database+ '..logregister ' '))
begin
alter   table   '+@database+ '..logregister   add   logtext_new   ntext
end
update   '+@database+ '..logregister   set   logtext_new=logtext
alter   table   '+@database+ '..logregister   drop   column   logtext
alter   table   '+@database+ '..logregister   add   logtext   ntext
update   '+@database+ '..logregister   set   logtext=logtext_new
alter   table   '+@database+ '..logregister   drop   column   logtext_new
end '
)

FETCH   NEXT   FROM   cursor_name  
INTO   @database
END

CLOSE   cursor_name
DEALLOCATE   cursor_name

这段代码执行不成功,会报找不到logtext_new找不到的错误,不知道怎么改

------解决方案--------------------
加了这句就没报错啊
------解决方案--------------------
up
------解决方案--------------------
Limpire(昨夜小楼) ( ) 信誉:100
说的有理!
up