Reputation: 73
I need to execute a dynamic query in SQL Server and show the result in a select query.
Since, we cannot use dynamic queries in functions, we have written a stored procedure to return the dynamic query value.
But how can i call my stored procedure in a select query.
Upvotes: 0
Views: 117
Reputation: 69594
You normally would use the key word EXEC
or EXECUTE
to call a stored procedure.
yet there is a way of selecting data from a stored procedure using OPENQUERY
.
SELECT * FROM
OPENQUERY(SERVERNAME, 'EXECUTE Proc_Name @parameters')
Upvotes: 1