将参数传递给sql server中的动态存储过程 [英] passing parameter to dynamic stored procedure in sql server

查看:77
本文介绍了将参数传递给sql server中的动态存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hii all
我有一个带有一个字符串参数的Adynaic存储过程,并且我在exec中有一个探针

hii all
i have adynaic stored procedure which takes one string parameter and i have a probel in the exec

set @With ='' With TableX as (''+ @sqlQuery + '') select * from TableX where Country = '' + @CountryName
print @With 



有人能告诉我它的正确语法吗?



can anyone tell me the correct syntax of it, please???

推荐答案

不确定我是否有完整的答案,但有一些发现:

1.您没有添加结尾的撇号,因此sql无效.
2. print只会将查询写入输出而不执行.
3.在SQL批处理中,必须首先执行公用表表达式(即以...开头的东西).
Not sure I have a complete answer, but some observations:

1. You''re not adding a trailing apostrophe so the sql is invalid.
2. print will only write the query to output and not execute it.
3. Common table expressions (ie. things that start With) have to be the first thing to execute in a SQL batch.


这篇关于将参数传递给sql server中的动态存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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