set问题
begin
declare @title varchar(20)
declare t_cursor cursor for select name from syscolumns where id=(select id from sysobjects where name= 'a_dpgj ') and type=39
open t_cursor
fetch next from t_cursor into @title
while @@fetch_status=0
begin
--insert into @t select id from dbo.f_getChild(@id)
--下面这一句话,不是得到@title的值而是把@title的值写成了 'cccaaaaaacc '
--请问如何让这个update语句成功
update a_dpgj set @title= 'cccaaaaaacc '
fetch next from t_cursor into @title
end
close t_cursor
deallocate t_cursor
end
[解决办法]
set @sql= 'update a_dpgj set '+@title + '= ' 'cccaaaaaacc ' ' '