Using SQL Server 2008 BCP utility to export a stored procedure (simple select) -


i trying run bcp utility sql server 2008.

i created simple stored procedure called get_gl_accounts

here stored procedure:

alter procedure [dbo].[get_gl_accounts]      select distinct           rtrim (s1.sgmntid) 'acccode',          rtrim (s1.dscriptn) 'codedesc',           case             when  s1.sgmtnumb = '1' '1'              when s1.sgmtnumb = '2' '2'             when s1.sgmtnumb = '3' '110'             when s1.sgmtnumb = '4' '4'             when s1.sgmtnumb = '5' '120'          end 'accounttype_id',          case              when s1.sgmtnumb = '2' left(s1.sgmntid, 2)             else 'default'          end 'accgroupname'                gl40200 s1       union        select            replace ([actnumbr_1]+'-'+ [actnumbr_2]+'-'+ [actnumbr_3]+'-'+[actnumbr_4]+'-'+  [actnumbr_5],' ', '') 'acccode',          '' 'codedesc',          '0' 'accounttype_id',          'default' 'accgroupname'                gl00100 

here bcp command:

exec xp_cmdshell 'bcp 'exec ncoa.dbo.get_gl_accounts' queryout "e:\dbexport\gl.txt"  -c -t, -t -s' 

when execute through sql server management studio getting following error message:

msg 8146, level 16, state 1, procedure get_gl_accounts, line 0
procedure get_gl_accounts has no parameters , arguments supplied.

do need parameters , arguments run this?

it looks issue how statement quoted. try instead:

exec xp_cmdshell 'bcp "exec ncoa.dbo.get_gl_accounts" queryout "e:\dbexport\gl.txt"  -c -t, -t -s' 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -