Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Capture SQL Messages

49 views
Skip to first unread message

dm_14

unread,
May 17, 2007, 9:27:00 PM5/17/07
to
How do capture SQL Messages ?

lets say I have a SQL stored procedure that use print statements. In query
analyser the results of the print statements they would appear in the message
tab. How can I capture these messages in a Power shell script ?

Thanks

Marco Shaw

unread,
May 18, 2007, 8:45:07 AM5/18/07
to

I was trying to show you a practical example using SMO, but cannot seem
to figure out how to run a stored procedure from it.

Normally, you're information will go directly to the console, but you
need to script that stored procedure to be run by a PowerShell script.

I can't explain it better than that right now.

What version of SQL? I think SMO is only supported with 2005, so that
might not even be an option.

Marco

Crito

unread,
May 18, 2007, 9:16:21 AM5/18/07
to

Use the sqlcmd utility with SQL Server 2005 or use isql (or osql if you
prefer) with previous versions.
'sqlcmd Utility'
(http://msdn2.microsoft.com/en-us/library/ms162773.aspx)
'isql Utility'
(http://msdn2.microsoft.com/en-us/library/aa214007(SQL.80).aspx)
'Running the osql Utility'
(http://msdn2.microsoft.com/en-us/library/aa213088(SQL.80).aspx)


--
Crito

RichS

unread,
May 18, 2007, 10:58:02 AM5/18/07
to
SMO is for management of SQL Server not data access

To run the stored proc you need to use ADO.NET. You could return the
information as output parameters. I'll put an example on my blog
--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk

Crito

unread,
May 18, 2007, 11:46:45 AM5/18/07
to

sqlcmd, isql and osql are the command line equivalents of query
analyzer. you'd use the exact same commands and you'd receive the exact
same results.


--
Crito

0 new messages