Windows Vista Forums

Capture SQL Messages

  1. #1


    dm_14 Guest

    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

  2. #2


    Marco Shaw Guest

    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

  3. #3



    Member
    Join Date : May 2007
    Posts : 30
    Local Time: 09:54 PM


     
    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

  4. #4


    RichS Guest

    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

  5. #5



    Member
    Join Date : May 2007
    Posts : 30
    Local Time: 09:54 PM


     
    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

Capture SQL Messages

Similar Threads
Thread Thread Starter Forum Replies Last Post
web photo capture J Alan Johnson Vista music pictures video 0 27 Apr 2009
ATI TV Wonder Pro A/V Capture Sergio Torres Virtual PC 2 03 Oct 2008
Still capture 'on -the-fly' from WMC? Ronin Vista music pictures video 2 09 Feb 2008
How can you capture individual thumbnails not full capture ? Roger Vista music pictures video 0 05 Nov 2007
Capture Eugene Vista music pictures video 0 15 Feb 2007