all groups > sql server programming > april 2007 >
You're in the

sql server programming

group:

Need help..


Need help.. Ankit Bhartia
4/15/2007 11:44:25 PM
sql server programming:

I am facing a peculiar problem with dynamic sql query.
I am using a dynamic query inside a SP. The query selects some data.
Now, what I am doing is that,I am getting the query text using a "PRINT"
and then trying to run it, I am getting the desired output. But when I
try to run the same dynamically generated script from SP using "EXEC
SP_EXECUTESQL" I am not getting any output. I am getting a empty
resultset.

Any suggestion, why am I facing this situation???

Re: Need help.. Uri Dimant
4/16/2007 12:00:00 AM
Ankit
Can you show us the script?

This works fine for me

DECLARE @sql nvarchar(4000)

SELECT @sql =
'SELECT o.OrderID, o.OrderDate, od.UnitPrice, od.Quantity
FROM Orders o
JOIN [Order Details] od ON o.OrderID = od.OrderID'

--PRINT @sql
EXEC sp_executesql @sql





[quoted text, click to view]

Re: Need help.. xyb
4/16/2007 12:59:44 AM
On 4=D4=C216=C8=D5, =CF=C2=CE=E72=CA=B144=B7=D6, Ankit Bhartia <ankit.bhar.=
[quoted text, click to view]
I think we can always debug our code at any forms such as print
crucial variables and Dynamic sqls :).
AddThis Social Bookmark Button