Results 1 to 9 of 9

Thread: Query output to file

  1. #1
    Join Date
    May 2007
    Posts
    10

    Query output to file

    Hi,

    I dont know if anyone has faced this problem.
    I have a database in SQL 2k, with a table xyz. I restore the same on SQL 2k5 enviornment.

    select * from xyz is executed in 2000 and 2005 query analyzer. The output is directed to text file.

    But the size of the file generated from 2005 is more (twice) than the one generated from 2000.

    I would like to know the reason for the same.

    Thanks & Regards
    Prachin

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    What's file type? Compared contents of those files?

  3. #3
    Join Date
    May 2007
    Posts
    10
    its a .txt file. The data is same in all fields as the table is restored from backup of 2000 database

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    Did you compare contents in those text files?

  5. #5
    Join Date
    May 2007
    Posts
    10
    no i did not compare
    why do i have to ?
    the table is same in both 2k and 2k5
    and i am giving a "select * from xyz" command
    u can test with your own data.

  6. #6
    Join Date
    Sep 2002
    Posts
    5,938
    The reason let you compare files is that I can't reproduce this issue on my servers. By the way, I'm not obligate to do testing for you.

  7. #7
    Join Date
    May 2007
    Posts
    10
    hi rmia0

    sorry if i offended you.
    what i meant is i know my data is same on both the enviorments, but the query to output file size is different. and i am looking for a answer for the same. If someone tries it on his/her machine and gets the answer it would solve my question.

    thanks

  8. #8
    Join Date
    Sep 2002
    Posts
    5,938
    As I said, I tested on my servers and can't reproduce this issue. It's possible to append data to file instead of replacing, and shouldn't be that hard to compare files. There is COMP command in dos.

  9. #9
    Join Date
    May 2007
    Posts
    10
    what i found out through someones help is that by default the file is saved in unicode format in 2k5.

    if the file is opened in notepad and saved in ANSI format the file size gets reduced.

    in 2k this option is avaliable when the results are saved to a file, but in 2k5 this option is not avaliable.

    so a bcp command can be used as follows

    bcp "select * from db.objectowner.tablename" queryout c:\200520.txt -Sservername/instancename -T -E -c -CACP

    the "-CACP" option does the formatting.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •