Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Execute Stored Procedure with Select Statement

Author  Topic 

pyu.agrawal
Starting Member

29 Posts

Posted - 2012-06-22 : 12:07:54
Is it possible to Execute Stored Procedure with Select Statement as Input Parameters, like:

EXEC spInventoryUpdate
SELECT ItemCode, Quantity FROM [TABLE]

I got this from: http://www.sqlservercentral.com/Forums/Topic978755-149-1.aspx

but it doesn't seem to work.

Thanks

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-06-22 : 15:37:03
I'm not even really clear on what you're trying to do, so feel free to ignore. But if you could change you sp to a udf, you could use the apply operator.

Select <stuff from udf>
From Table
CROSS APPLY dbo.udf_ToReplaceSproc(ItemCode,QUantity) a

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-22 : 22:58:27
you can do like below for invoking store procedure using select. But for passing parameters you might be better off making it into udf as Jimf suggested



http://beyondrelational.com/modules/2/blogs/70/posts/10812/select-columns-from-exec-procedurename-is-this-possible.aspx


Between can you explain why you're trying to do this?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -