Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

can i get result of EXEC sp_executeSQL as record set? Expand / Collapse
Author
Message
Posted Wednesday, October 31, 2012 11:25 PM


Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Sunday, May 05, 2013 11:09 PM
Points: 66, Visits: 260
DECLARE @query nvarchar(MAX) ;

set @query = 'SELECT * FROM Products' ;
EXEC sp_executeSQL @query

is this query return the record set as normal 'SELECT * FROM Products' query?
Post #1379622
Posted Wednesday, October 31, 2012 11:35 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, March 01, 2013 6:16 AM
Points: 81, Visits: 286
Yes it will.
with respect to performance it may different. but result will be same
Post #1379623
Posted Wednesday, October 31, 2012 11:37 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 8:37 PM
Points: 2,370, Visits: 3,252
While it will, you won't be able to manipulate results in the client.

To do that, you'd need to INSERT into a temporary table within the dynamic SQL. That table, defined in advance in the client, would then contain the results of the query in the temp table, which could then be used in the client.

Obviously, you should not use SELECT * (use explicit column names).



No loops! No CURSORs! No RBAR! Hoo-uh!

INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?

Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Are you too recursively challenged?
Splitting strings based on patterns can be fast!
Post #1379624
Posted Thursday, November 01, 2012 1:42 AM


Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Sunday, May 05, 2013 11:09 PM
Points: 66, Visits: 260
thanks
Post #1379651
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse