Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2002
    Posts
    5

    Unhappy Unanswered: Use ASP to output the BCP data from SQL Server

    I am the beginner of the develope.
    Now I need to write a ASP to out put the BCP text file.
    First I already write the query in Enterprise Manager Stored Procedure. But the next step I don't know how to write it.
    I have serach the site for output the BCP, but I am not sure where I should write in.

    This is the scource of DOS out put

    BCP "select * from vw_table" queryout Table.CSV -c -t"" -r\n -e Error.txt -m100 -Usa -Padmin -SDB

    Is that i still use this in the ASP or Stored Procedure?

    Sorry I am new in this field so please help me lots.
    Thank you.

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    Are you planning on using the xp_cmdshell extended stored procedure ?

  3. #3
    Join Date
    Jul 2002
    Posts
    5
    Actually I am the first time to write it. So any suggestion is fine for me.
    I only need to output it from ASP form through the SQL server.

    Or do i need to complete to write the BCP in stored procedure then exec in ASP? But now i still cannot output the file from the Query analyzer.

    it is what i am trying......
    exec master..xp_cmdshell 'bcp "select top 10 * from DB.dbo.vw_Hak" queryout "c:\HAK.CSV"
    -c -t"" -r\n -e Error.txt -m100 -Usa -P"" -S"MyServer"'


    Originally posted by rnealejr
    Are you planning on using the xp_cmdshell extended stored procedure ?

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    Try the following:

    execute xp_cmdshell 'bcp "select top 10 * from DB.dbo.vw_Hak" queryout c:\HAK.csv -c -t -Usa -P -SMyServer'

  5. #5
    Join Date
    Jul 2002
    Posts
    5
    Thanks so much! Now i tried in Query analyzer and it out the message "copied". It suppose in the drive c has the csv file but I couldn't find it. Is that it will copy to the server drive c but not my PC (client) drive c????

    Sorry asking so much. But really help me alot.

  6. #6
    Join Date
    Feb 2002
    Posts
    2,232
    Yes, you are correct.

  7. #7
    Join Date
    Jul 2002
    Posts
    5
    any way can copy to the client driver ? even i setup the file path in ASP , it won't be use?

Posting Permissions

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