带有OUTPUT语法帮助的动态SQL [英] Dynamic SQL with OUTPUT syntax help

查看:75
本文介绍了带有OUTPUT语法帮助的动态SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想编写一个动态SQL查询代码,但我的语法错误会妨碍我。请帮我解决以下问题:



Hello, i want to code a dynamic SQL query yet syntax errors on my part get in my way. Please help me with the following:

SET @dynamicSQLCommand1 =
    'SELECT @CDT = SELECT TOP 1 DataTime FROM  DestinationDatabase.dbo.' + @CurrentTable + ' ORDER BY DataTime DESC '
    EXEC sp_executesql @dynamicSQLCommand1, N'@CDT nvarchar(500) OUTPUT', @CDT = @CurrentDataTime OUTPUT





我收到SELECT TOP 1部分的错误。但我无法真正理解语法问题。

感谢您的帮助。



I get the error with the SELECT TOP 1 part. Yet i can't really understand the syntax issue.
Thanks for help.

推荐答案

您好,



查看这个...





如何将表的第一个值分配给变量 [ ^ ]



希望这会对你有所帮助。





干杯
Hi,

Check this one...


how to allocate table first value to a variable[^]

Hope this will help you.


Cheers


这篇关于带有OUTPUT语法帮助的动态SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆