Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 BCP - Stored Procedure - Parameters

Author  Topic 

mapidea
Posting Yak Master

124 Posts

Posted - 2010-02-23 : 14:15:19
I get the error when I pass orders_ids separated by commas ...... too many argument specified.

dvx_5_Export_ExportedData is a stored proc.

How can I bcp a stored proc with parameters.

ALTER PROCEDURE [dbo].[dvx_5_Export_GetTheExportData]
@order_ids VARCHAR(3000)
AS
BEGIN

declare @sql varchar(8000)
select @sql = 'bcp "EXEC CTA_Web7..[dvx_5_Export_ExportedData]' + @order_ids + '" queryout E:\Sai\sysobjects.txt -c -t, -T -S' + @@servername

exec master..xp_cmdshell @sql

END

mapidea
Posting Yak Master

124 Posts

Posted - 2010-02-23 : 14:40:41
It was
select @sql = 'bcp "EXEC CTA_Web7..[dvx_5_Export_ExportedData] ''' + @order_ids + '''" queryout E:\Sai\sysobjects.txt -c -t, -T -S' + @@servername

Thanks.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-02-23 : 14:55:23
Change the

exec master..xp_cmdshell @sql

to

PRINT @sql

until you have the syntax "nailed"
Go to Top of Page
   

- Advertisement -