DECLARE @str VARCHAR (MAX); SELECT @str = COALESCE(@str + CHAR(10),'') + 'EXECUTE CreateDeno ' + CAST(ID AS VARCHAR) FROM GL_To_Batch_Details WHERE TYPE = 'C' AND Deno_ID IS NULL; --PRINT @str;--SELECT @str; **EXEC(@str);**
EDITED
EXECUTE语句是否将字符串截断为8,000个字符,如PRINT?如何执行具有超过8,000个字符的动态sql语句?
任何建议都会受到热烈的赞赏.