SQL Server Performance

sql statement that don't run in sql server 2000

Discussion in 'Non-Transact SQL Developer Performance Tuning' started by vhmau, Jun 12, 2006.

  1. vhmau New Member

    Hi everyone
    I have this vb6 code:
    strSql = "select * into [text; FMT=Delimited; HDR=Yes; Database=c: emp].[TC.txt] from Employees"
    con.Execute strSql
    if my con connects to access database, this bulk of code run ok. If my con connects to Sql server 2000 database, this bulk of code returns error.
    Can anyone shows me how to do in Sql server 2000 to get the same result as when running this code with access database ?.
    Thanks.
  2. ranjitjain New Member

    read about bulk copy program(bcp) in BOL to import/export data into text file
  3. satya Moderator

    What was the error generated?
    ALso check the privileges of the account used to run this code.

    Satya SKJ
    Microsoft SQL Server MVP
    Contributing Editor & Forums Moderator
    http://www.SQL-Server-Performance.Com
    This posting is provided �AS IS� with no rights for the sake of knowledge sharing.
  4. Adriaan New Member

    Satya, the statement looks like a Jet/ADO thingy. I don't think it could work in T-SQL at all.

    Like Ranitjain said, he should use BCP - which unfortunately is not the easiest thing to set up, since it's a command-line utility.
  5. satya Moderator

    Adriaan
    Thats true, but I feel even with that you can run the code in TSQL and there is a way out if the originator comes with exact problem. As you can see the content of the question seems to be bit vague.

    Satya SKJ
    Microsoft SQL Server MVP
    Contributing Editor & Forums Moderator
    http://www.SQL-Server-Performance.Com
    This posting is provided �AS IS� with no rights for the sake of knowledge sharing.
  6. Madhivanan Moderator

    Try this

    Exec Master..xp_Cmdshell 'bcp "Select * from DBName..Employees" queryout "C: empTC.txt" -c'

    Madhivanan

    Failing to plan is Planning to fail

Share This Page