Help in BCP

  • I'm using the following snippet to export the data to excel.... but i keep on getting the following error

    Declare @StrBCPCmd varchar(8000)

    SET @StrBCPCmd = ' bcp ' + ' "exec eCatalogSBILife.dbo.usp_loy_GetIndSalesReport ''3'',''CIRCLE'', ''00'', ''BHOPAL'', NULL, 0, NULL " ' + ' queryout ' + ' c:\temp\test1.xls -w -C ACP '

    exec master..xp_cmdshell @StrBCPCmd

    SQLState = S1000, NativeError = 0

    Error = [Microsoft][ODBC SQL Server Driver]Host-file columns may be skipped only when copying into the Server

    Thanks for any help.

    --Ramesh


  • not sure if you can bcp from proc. As far as I know, can only bcp from table, view and query.

    what you can do is grab the result set returned from proc and put into a temp table and bcp out from there.

    eg. insert into #temp

         exec proc

    I think you also have syntax errors - missing BCP argument options.

    eg. -S - server, -U login etc..

     

  • ND, you are wrong. I use to create reports by direct call of SP from bcp. It's really flexible and manageble way. Recommend to try.

    Ramesh, your bcp call is incomplete. Check out BOL for bcp arguments. And you probably need to use format file. BOL has pretty good explanation how to build and use it.

    _____________
    Code for TallyGenerator

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply