Ask the Expert

Not getting a result set when executing a stored procedure

I created a stored procedure to return me a select statement. See below:

 select nameA from tableA Union Select nameB from tableB
I tried the statement above in the Query Analyzer, and it returned to me a result set. But when I executed it from a stored procedure, I can't get a result set, but I get "The command(s) completed successfully." Did I miss some step to make it return a result set? I am using SQL Server 7.0.

    Requires Free Membership to View

I cannot duplicate the problem you are experiencing.

I, like you, created a stored procedure (using Northwind):

 create procedure usp_mailingLabels as select firstName + ' ' + lastName as contactName from employees union select contactName from customers
However, I was able to execute the procedure and get a result set:
 exec usp_mailingLabels output: contactName Alejandra Camino Alexander Feuer Ana Trujillo . . . Yoshi Tannamuri Yvonne Moncada Zbyszek Piestrzeniewicz

 

For More Information

This was first published in April 2002

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.