SQLCMD to export data in txt file

  • Comments posted to this topic are about the item SQLCMD to export data in txt file

    Sheraz Mirza::hehe:

  • Hi Sheraz.Mirza,

    Very interesting script this. Tell me is there a way to output this in comma delimited format without having to concatenate the fields?

    Manie Verster
    Developer
    Johannesburg
    South Africa

    I am happy because I choose to be happy.
    I just love my job!!!

  • Haven't really used it this way before. Thanks for the short lesson.

  • You can use the lowercase s option from the command-line (-s",") or the SQLCMDCOLSEP variable (set SQLCMDCOLSEP=,)

    You need to be careful how you specify options in .BAT/.CMD because comma can used to separate commands.

  • Boss, a very simple and easy way for comma seperated value is, just put file extension as (.csv) , and it will generate microsoft excel comma seperated file

    Sheraz Mirza::hehe:

  • Sheraz.Mirza (10/17/2016)


    Boss, a very simple and easy way for comma seperated value is, just put file extension as (.csv) , and it will generate microsoft excel comma seperated file

    Nope, I tried that and it did not work. Put everything in one column but thanks anyway.

    Manie Verster
    Developer
    Johannesburg
    South Africa

    I am happy because I choose to be happy.
    I just love my job!!!

  • I tried it again on command prompt , and its working

    Sheraz Mirza::hehe:

  • Very weird result. I have text all over the place in the textfile when it's a from a table I recently made, but it works fine with one of the Adventure Works ones. Tried making a brand new one and again it puts a lot of spaces where there is none. Dropped it and made it again where all the columns were varchar 10, 15... and up to 30, and then it looked nice. So don't use max in your columns if you use this, or convert it first.

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

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