Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invoke-Sqlcmd get query output and messages

Status
Not open for further replies.

ianmcwright

Programmer
May 29, 2012
1
GB
Hi

From this simple sp I want to get the result of OutPutInt1 into a variable and the print statements in a text file.

CREATE PROC SP_TEST
AS
PRINT 'this is my output'
PRINT 'this is should be in the text file'
SELECT OutPutInt1 = 999

I'm trying things like:

$CommandQuery = "'EXEC SP_TEST'"
$OutPutInt1 = Invoke-Sqlcmd -AbortOnError -ServerInstance $SQLServerName -Database $Databasename -Query $CommandQuery -QueryTimeout 0 2>> $SQLLogFile

I can get the results output or the messages but not both, any ideas?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top