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

核心:exec(sqlcommand)

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

 

 

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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2021-07-19
  • 2021-06-12
  • 2021-12-15
  • 2021-11-08
猜你喜欢
  • 2022-12-23
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案