Saving Query results as CSV file in SQL Server 2005

  • tracy, you're a life saver!

  • Now that we have it figured out how to save a file in a different format, how do we set the default to our preference? I don't want to click the drop down each time I want to save a stored procedure change... Any one know where to set the default file save as format?

  • Tracy U R AWESOME!!

  • FOUND ANOTHER WAY...

    WRITE YOUR QUERY IN THE QUERY ANALYZER

    QUERY -> RESULTS TO -> RESULTS TO FILE

    EXECUTE QUERY

    SAVE FILE AS .xls

    DONE....

  • Thanks you SO MUCH.

    I will try it today!

    Regards,Yelena Varsha

  • Have you tried the option of importing the file as data?

    When accessing output files this way, you can set how the file is delimited:

    In Excel:

    select

    Data

    Import External Data

    Import Data

    Browse to file

    Select file (all files - files of type)

    After selecting the file you can select the many options of the format of the file.

    Hope this Helps

    Mae

  • Hello there,

    can any one help me by expalining me how to take CSV files to SQL SERVER 2000 ???

    i am in desperate need of it.

  • There are several ways and some depend on the condition of the data. The way with the most performance is Bulk Insert... I recommend you take a look at it in Books Online because it has a fair number of options.

    Of course, you could also use BCP, DTS, a Linked Server, OPENROWSET, and a couple of other methods.

    If you just want to do it once, then open Enterprise Manager and look in the {Tools} menu for {Data Transformation Services}.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • THANKS!!!

    Been spinning my wheels on this one for months.

  • I am trying to use a bcp in 2005 and the file is continually going out as Unicode when I am trying to define it (or at least i think I am) as ANSI. Does anyone have a scripted solution for exporting files via bcp as ANSI?

    Sample of code that is still exporting as Unicode:

    SET @String = 'bcp "SELECT * FROM Db_NAME.dbo.qry_file" QUERYOUT ' + @Path + @File + ' -c -S ' + @Server + ' -T'

  • /bump

  • /bump

  • /bump

  • mckinnj1 (7/7/2009)


    I am trying to use a bcp in 2005 and the file is continually going out as Unicode when I am trying to define it (or at least i think I am) as ANSI. Does anyone have a scripted solution for exporting files via bcp as ANSI?

    Sample of code that is still exporting as Unicode:

    SET @String = 'bcp "SELECT * FROM Db_NAME.dbo.qry_file" QUERYOUT ' + @Path + @File + ' -c -S ' + @Server + ' -T'

    Are the columns in the qry_file table NVARCHAR?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (7/8/2009)


    mckinnj1 (7/7/2009)


    I am trying to use a bcp in 2005 and the file is continually going out as Unicode when I am trying to define it (or at least i think I am) as ANSI. Does anyone have a scripted solution for exporting files via bcp as ANSI?

    Sample of code that is still exporting as Unicode:

    SET @String = 'bcp "SELECT * FROM Db_NAME.dbo.qry_file" QUERYOUT ' + @Path + @File + ' -c -S ' + @Server + ' -T'

    Are the columns in the qry_file table NVARCHAR?

    No they are CHAR.

Viewing 15 posts - 16 through 30 (of 34 total)

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