SPOOLING

  • I was wondering if any one could help me out. I'm trying to spool the results from a tsql script to a text file. I'm haveing trouble finding a way to do this. Please if you know how to do this please help me.

    rich

    RICHARD KIRMSS


    RICHARD KIRMSS

  • You can redirect the output using osql and the ">" operator. There is also an option in QA to save to a file.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • i'm trying to run this simple test script using the osql utility

    exec master..xp_cmdshell 'osql -Q"select * from %syslogins..master%" -oH:\testfile\stats.txt'

    and i'm getting this error message

    cannot open output file

    no such file or directory.

    - I have created the file and I still get the same error.

    any ideas?

    thanks rich

    RICHARD KIRMSS


    RICHARD KIRMSS

  • I'm sorry i gave the query it is suppost to be select * from master..sysobjects.

    i'm still getting the same error however.

    rich

    RICHARD KIRMSS


    RICHARD KIRMSS

  • Confirmed that you have permissions to the folder?

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • yeah i have all the permissions to the file. and I still get the error message

    RICHARD KIRMSS


    RICHARD KIRMSS

  • ok i've checked the permissions on the file that i'm trying to write to, and I'm still coming up with the same error. Any idea on what I might be doing wrong?

    thanks rich

    RICHARD KIRMSS


    RICHARD KIRMSS

  • hi, is de H; drive mapped with the sql server account?

  • ok i've figured out the problem I wasn't specifiying the full server name. Thank you for your help. I have one more question however. I was noticing that when you pipe the output of the query to a file the last statement is the the only one to get piped to the output. I was wondering if there is a way to append other output to the file that you are piping to.

    Thank you once again,

    Rich

    RICHARD KIRMSS


    RICHARD KIRMSS

  • osql .... > filename

    is a new file.

    osql ... >> filename

    appends to the file. See my series on version control, part 3 for more info.

    Steve Jones

    steve@dkranch.net

  • Steve,

    Thank you very much I over looked the double ">".

    Rich

    RICHARD KIRMSS


    RICHARD KIRMSS

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply