函数:exec(sqlcommand)执行动态sql

declare @sql nvarchar(4000)
set @sql='select getdate()'
exec (@sql)

核心:exec(sqlcommand)

动态拼接sql命令,然后用exec(sqlcommand)执行该命令

 

 

注:用这个写的存储过程所返回的结果集不知道能不能被客户端代码获得。---没空验证

posted on 2011-09-15 17:37  雨渐渐  阅读(732)  评论(0编辑  收藏  举报

导航