Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Capture SQL Messages

Reply
 
Old 05-17-2007   #1 (permalink)
dm_14


 
 

Capture SQL Messages

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

My System SpecsSystem Spec
Old 05-18-2007   #2 (permalink)
Marco Shaw


 
 

Re: Capture SQL Messages

dm_14 wrote:
> 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


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
My System SpecsSystem Spec
Old 05-18-2007   #3 (permalink)


 
 

Use the sqlcmd utility with SQL Server 2005 or use isql (or osql if you prefer) with previous versions.
sqlcmd Utility
isql Utility
Running the osql Utility
My System SpecsSystem Spec
Old 05-18-2007   #4 (permalink)
RichS


 
 

Re: Capture SQL Messages

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" wrote:

>
> 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/lib...7(SQL.80).aspx)
> 'Running the osql Utility'
> (http://msdn2.microsoft.com/en-us/lib...8(SQL.80).aspx)
>
>
> --
> Crito
>

My System SpecsSystem Spec
Old 05-18-2007   #5 (permalink)


 
 

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.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
ATI TV Wonder Pro A/V Capture Virtual PC
Video Capture Vista General
How can you capture individual thumbnails not full capture ? Vista music pictures video
Capture Vista music pictures video
Capture com events PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46