Reputation: 25631
I'm trying to debug\execute a SP from t-sql (sql server 2008) and when I execute the following sql it returns only a message 'Command(s) completed successfully'.
I know the SP is returning the data in a table via the @RETURN_VALUE parameter, how do I get this to display in sql query window.
exec STARMS.dbo.GetMetaData @@Assembly=13366,@@Namespace=NULL,@@ParameterName=NULL,@@Standard=0,@@Timestamp=NULL
The SP looks something like this ( removed the main body) the interesting part is the creation of the temp table and then returning the contents of the temp table:
CREATE PROCEDURE [dbo].[GetMetaData]
@@Assembly Sql_Variant = NULL,
@@Namespace Varchar(30) = NULL,
@@ParameterName Varchar(40) = NULL,
@@Standard Bit = 0,
@@Timestamp DateTime = NULL
AS
SET NOCOUNT ON
DECLARE @ResultTable TABLE (AssemblyId Int, Namespace Varchar(30), ParameterName Varchar(40), Value Varchar(100))
-- Does loads of stuff and then inserts into @ResultTable table...
SET NOCOUNT OFF
-- Return the result
SELECT AssemblyId, Namespace, ParameterName, [Value]
FROM @ResultTable
RETURN
Note: the reason I'm asking the question is because I'm trying to look at the performance of the SP in SQL Server 2008 and I'm unsure why this doesn't return the data in the query window.
Upvotes: 1
Views: 888
Reputation: 21756
Check your full code of SP, may be somewhere there is a RETURN statement, so - the SP will not return any data (pay attention on IF SomeContition IS TRUE RETURN
):
CREATE PROCEDURE [dbo].[GetMetaData]
@@Assembly Sql_Variant = NULL,
@@Namespace Varchar(30) = NULL,
@@ParameterName Varchar(40) = NULL,
@@Standard Bit = 0,
@@Timestamp DateTime = NULL
AS
SET NOCOUNT ON
DECLARE @ResultTable TABLE (AssemblyId Int, Namespace Varchar(30), ParameterName Varchar(40), Value Varchar(100))
-- Does loads of stuff and then inserts into @ResultTable table...
IF SomeContition IS TRUE RETURN
SET NOCOUNT OFF
-- Return the result
SELECT AssemblyId, Namespace, ParameterName, [Value]
FROM @ResultTable
RETURN
Upvotes: 2