Results 1 to 2 of 2

Thread: exporting data from MSSQL 2K

  1. #1
    Join Date
    May 2005
    Posts
    111

    exporting data from MSSQL 2K

    other than dts, is there a way to export data from a table in sql to a text file on the OS? our oracle dba mentioned something about spooling in oracle and we were curious if mssql had any alternatives for exporting.

  2. #2
    Join Date
    Dec 2004
    Posts
    502
    You can use "bcp", which is a command line utility for SQL Server. You can use it like this:

    bcp YourDatabase..YourTable out c:\YourTextFile.txt -c -Uuser -Ppassword -Sserver

    Type "bcp /?" from the command line to see all other options.

    You can also use "osql", another command line utility that allows you to execute sql commands:

    osql -Uuser -Ppassword -Sserver -Q"select * from YourDatabase..YourTable" > c:\YourTextFile.txt

    This will include column headers, whereas bcp will not.

Posting Permissions

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