0

MSSQL has a PRINT command which lets me write output from stored procedures and sql text queries. The problem is that this output is not returned when calling through SqlDataAdapater using Fill method.

I am not sure why but if Print is not possible to use then maybe there is an alternative pipe:ing output to result?

3 Answers 3

1

No, anything that you want needs to be returned with the 'result'.

You could in theory use an OUT parameter and add additional information to this.

Using a Stored Procedure with Output Parameters

Sign up to request clarification or add additional context in comments.

Comments

1

PRINT output is received via the connection's InfoMessage event. So technically you could collect them separately and merge. However, I would advise you to use either SELECT or out parameters / the return value, to communicate information from a command.

Comments

1

You simply get the data from the select command or you can use the return
simple example

USE AdventureWorks2012;
GO
CREATE PROCEDURE checkstate @param varchar(11)
AS
IF (SELECT StateProvince FROM Person.vAdditionalContactInfo WHERE ContactID = @param) = 'WA'
    RETURN 1
ELSE
    RETURN 2;
GO

here you can use select also instead of return

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.