Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2007
    Posts
    20

    Unanswered: Help with a query

    Ive been trying to find out how to write a query like this for months now and feel its time that I get some help

    Im trying to export columns to text files so that they can be accessed via a website to show statistics.
    (My SQL database is used for something else and I do not want the website directly connecting to it.)

    So first I would have the table ordered by a specific column and then export the top 50 results for example.
    I had it working to export to excell but I lost the query


    Do I use something like EXPORT COLUMNS or INSERT INTO text file sorta thing
    Thanks

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi Paul

    irrespective of the purpose of the db I would have the website access it directly. Why are you unhappy with this?

    In any event BCP is an efficient way to get data out of the db and into text files.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Apr 2007
    Posts
    20
    I dont want to lean on the SQL performance and im sure constant connections like this would.

    I have never used BCP before so I guess I will go and have a look into that
    thanks

  4. #4
    Join Date
    Apr 2007
    Posts
    20
    Still no luck BCP is very confusing

  5. #5
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    is it? it's just a console app. here's how you can export data for an entire table:

    bcp MyDatabase.dbo.MyTable out myfile.txt -c -T -SMYSERVER

    and here's how to export the result of a query:

    bcp "select foo from MyDatabase.dbo.MyTable where bar=12" out myfile.txt -c -T -SMYSERVER

Posting Permissions

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