是否可以在调用时向存储过程添加子句 [英] Is it possible to add a clause to a Stored Procedure when calling it

查看:65
本文介绍了是否可以在调用时向存储过程添加子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从代码中调用存储过程时是否可以添加子句; C#?我有存储过程,我需要添加子句FOR XML AUTO或FOR XML RAW,但我没有写入访问权限,因为它的客户端存储过程。我知道最容易让他们改变它,但是,我不想放弃首先创建我们自己的解决方案。



任何想法?

Is it possible to add a clause to a Stored Procedure when calling it from your code; C#? I have Stored Procedure for which I need to add the clause "FOR XML AUTO" or "FOR XML RAW", but I do not have write access to change since its our clients stored procedure. I know the easiest would be to have them change it, however, I do not want to give up on creating our own solution first.

Any ideas?

推荐答案

是的,你可以使用现有sp的结果来做到这一点。希望这会有所帮助

Yes you can do this using result of existing sp. Hope this will be helpful
DECLARE @cache TABLE (CountCol int NOT NULL)
INSERT @cache EXECUTE usp_Yoursp @Id=123
SELECT CountCol FROM @cache FOR XML AUTO


按如下方式准备SQL以调用SP并将结果作为XML返回。然后从C#调用此SQL。



例如

从SPName()中选择*用于xml auto
Prepare an SQL as follows to call SP and return the result as XML. Then call this SQL from C#.

e.g.
select * from SPName() for xml auto


这篇关于是否可以在调用时向存储过程添加子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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