我正在尝试从SQL Server 2008运行BCP
实用程序。
我创建了一个名为GET_GL_ACCOUNTS
这是存储过程:
ALTER PROCEDURE [dbo].[GET_GL_ACCOUNTS]
AS
SELECT DISTINCT
RTRIM (s1.SGMNTID) AS 'AccCode',
RTRIM (s1.DSCRIPTN) AS 'CodeDesc',
CASE
WHEN s1.SGMTNUMB = '1' THEN '1'
WHEN s1.SGMTNUMB = '2' THEN '2'
WHEN s1.SGMTNUMB = '3' THEN '110'
WHEN s1.SGMTNUMB = '4' THEN '4'
WHEN s1.SGMTNUMB = '5' THEN '120'
END AS 'AccountType_id',
CASE
WHEN s1.SGMTNUMB = '2' THEN LEFT(s1.SGMNTID, 2)
ELSE 'DEFAULT'
END AS 'AccGroupName'
FROM
GL40200 s1
UNION
SELECT
REPLACE ([ACTNUMBR_1]+'-'+ [ACTNUMBR_2]+'-'+ [ACTNUMBR_3]+'-'+[ACTNUMBR_4]+'-'+ [ACTNUMBR_5],' ', '') AS 'AccCode',
'' AS 'CodeDesc',
'0' AS 'AccountType_id',
'Default' AS 'AccGroupName'
FROM
GL00100 a
这是我的BCP
命令:
EXEC xp_cmdshell 'bcp 'EXEC NCOA.dbo.GET_GL_ACCOUNTS' QUERYOUT "E:\dbexport\gl.txt" -c -t, -T -S'
当我通过SQL Server Management Studio执行此操作时,收到以下错误消息:
Msg 8146,Level 16,State 1,Procedure GET_GL_ACCOUNTS,Line 0
过程GET_GL_ACCOUNTS没有提供参数和参数。
我需要参数和参数来运行吗?
答案 0 :(得分:1)
看起来您的问题是语句的引用方式。试试这个:
EXEC xp_cmdshell 'bcp "EXEC NCOA.dbo.GET_GL_ACCOUNTS" QUERYOUT "E:\dbexport\gl.txt" -c -t, -T -S'