Results 1 to 2 of 2

Thread: SP and BCP

  1. #1
    Join Date
    May 2005

    Unanswered: SP and BCP

    Hi I am trying to use BCP to save the results of an SP to a file here is my code

    DECLARE @Cmd VARCHAR(1000)

    SELECT @Cmd = 'bcp "exec mydatabase..my_sp" QUERYOUT "d:\reports\bob.csv" -w -t"," -T'

    EXEC master..xp_cmdshell @Cmd

    I get invaild object errors on temp tables used within the SP.

    Help desperatly need thanks

  2. #2
    Join Date
    Jun 2003

    Thumbs up Re

    there is anotherway to do the same job,but output is not that grt.
    see sample code:

    use pubs
    create proc tt
    select au_id,au_lname,au_fname,contract into #tt1 from authors
    select * from #tt1
    ----- give ur servername in -S give -U username -P password 
    EXEC master..xp_cmdshell 'osql -S urserver -U username -P password -q " set nocount on exec set nocount off" -o "d:\reports\bob.csv" -h-1 -s","'
    ------drop proc------
    drop proc tt
    I love cursor,though I never use it.Cos' I dont want to misuse it.


Posting Permissions

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