Capture TSQL Message Result

Hi,

I want to save Message printed in the Message tab when we run the TSQL.

I need something like

set @a= Messages printed below

Message

Regards

August 28th, 2015 9:16am

When you execute the T-SQL script (-i option) with SQLCMD, you can capture results & messages mixed in an output file (-o  option).

SQLCMD tutorial: https://technet.microsoft.com/en-US/library/ms170207(v=SQL.105).aspx

Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 9:18am

If you only need the number of the rows from your query, you can use

@@ROWCOUNT

August 28th, 2015 9:20am

I want to Capture the Message to a variable within the TSQL script. SQLCMD, PowerShell and other utilities I'm aware.
Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 10:59am

I'm not particularly looking of the row count, I want to save a message to a variable irrespective of the TSQL Command.
August 28th, 2015 11:01am

>I want to save a message to a variable irrespective of the TSQL Command.

I am afraid that is not possible.

Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 11:25am

That message is not produced by SQL Server, but by the query tool. All that SQL Server produces is the number which it sends on the TDS stack.

August 28th, 2015 4:54pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics