Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2004
    Posts
    3

    Unanswered: output table content to a textfile (was "Need help on SQL!!!")

    Hi.. anyone know wat the syntax to output the table content to a textfile? and copy back the content on the textfile back to the table?

    Must use SQL command for MS SQL Server 2000 cannot use manual.. tks!

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    There is no native SQL command to do this.
    Use either the BCP (Bulk Copy) Utility or the DTS tool. Look them up in Books Online for more details.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Quote Originally Posted by kshen
    Must use SQL command for MS SQL Server 2000 cannot use manual.. tks!
    Can you use the Books Online?

    -PatP

  4. #4
    Join Date
    Dec 2004
    Posts
    3
    i couldn't find... thats y I ask here... =(

  5. #5
    Join Date
    Dec 2004
    Posts
    3
    Quote Originally Posted by blindman
    There is no native SQL command to do this.
    Use either the BCP (Bulk Copy) Utility or the DTS tool. Look them up in Books Online for more details.

    how do i use BCP then? syntax?

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Books Online should be installed with SQL Server. You should have it in your Start menu.

    BCP is a command line utility, so from within SQL Server you would need a script that shells out to the command prompt (xp_cmdshell) and executes your statement. BCP has many options, which are all listed in the documentation.

    DTS is probably a better option for you. It is designed for transferring data between many different formats and platforms. You can find in in Enterprise Manager (the Data Transformation Services tab). First, create your DTS package for transferring data. Then call the package from your script or as a scheduled job.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  7. #7
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Oh, for the love of...

    Code:
    USE Northwind
    GO
    
    DECLARE @cmd varchar(8000)
    SELECT @cmd = 'bcp Northwind.dbo.Orders out c:\Orders.dat -SNJROS1D151\NJROS1D151DEV -Usa -Ppassword -c'
    EXEC master..xp_cmdshell @cmd
    GO
    Ever try and release DTS from a dev environment to a production environment?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  8. #8
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    I'm not a big fan of DTS. But BCP can be a bit finicky too. The poster really needs to check out Books Online to decide what is best for his situation.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

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