sql server 2005 - BCP Function sequence error when running proc with parameters -


i have been trying create stored procedure uses dynamic sql assemble bcp command export data parameterized stored procedure csv file.

was getting host data file access issue think filesystem permissions.

now consistantly fillowing error when run proc:

sqlstate = s1010, nativeerror = 0 error = [microsoft][sql server native client 10.0]function sequence error

the proc code follows:

alter procedure [dbo].[sp_makemarketinglistexports]          @includeinservice varchar(1) = null,         @includemlm varchar(1) = null,         @includequotenoodle varchar(1) = null,         @netective varchar(1) = null,         @cyberchex varchar(1) = null,         @agentsadvantage varchar(1) = null,         @quotenoodle varchar(1) = null,         @mlmlistsubscriber varchar(1) = null,         @state varchar(10) = null,         @mailerid varchar(10) = null,         @filepath varchar(250) begin         -- set nocount on added prevent result sets         -- interfering select statements.         set nocount on;          declare @command varchar(500);          set @command = 'bcp "exec internalml..sp_selectmarketinglistmembers '                                 + '@includeinservice = ' + coalesce(@includeinservice, 'null') + ', '                                 + '@includemlm = ' + coalesce(@includemlm, 'null') + ', '                                 + '@includequotenoodle = ' + coalesce(@includequotenoodle, 'null') + ', '                                 + '@netective = ' + coalesce(@netective, 'null') + ', '                                 + '@cyberchex = ' + coalesce(@cyberchex, 'null') + ', '                                 + '@agentsadvantage = ' + coalesce(@agentsadvantage, 'null') + ', '                                 + '@quotenoodle = ' + coalesce(@quotenoodle, 'null') + ', '                                 + '@mlmlistsubscriber = ' + coalesce(@mlmlistsubscriber, 'null') + ', '                                 + '@state = ' + coalesce(@state, 'null') + '"'                                 + ' queryout ' + coalesce(@filepath, 'null')                                 + ' -c -t -s ' + @@servername          select @command;          exec xp_cmdshell @command; end 

i use select @command assembled command analysis.

have had parameter names calle proc included command came out like:

bcp "exec internalml..sp_selectmarketinglistmembers @includeinservice = null, @includemlm = null, @includequotenoodle = null, @netective = null, @cyberchex = null, @agentsadvantage = null, @quotenoodle = null, @mlmlistsubscriber = null, @state = null" queryout c:\temp\test.csv -c -t -s spkd18

also did without parameter names same function sequenc error message:

bcp "exec internalml.dbo.sp_selectmarketinglistmembers null, null, null, null, null, null, null, null, @state = null" queryout "c:\\temp\test.csv" -c -t -s spkd18

any insight on why not working? btw, have run bcp via proc , copied command prompt same results. problem can't find on internet error, because generic.

i can run internalml.dbo.sp_selectmarketinglistmembers proc parameters directly in ssms query window pretty sure has bcp.

thanks

bcp execute following resolve format of resultset. can tell result of this:

set fmtonly on      exec sp_selectmarketinglistmembers <your input params>; set fmtonly off 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -