这是我的代码
USE [test]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[DO_CUSTOMER_DAILY]
@tmpVar BIGINT,
@V_SQL_TMP VARCHAR (4000),
@V_DIRECTORY VARCHAR (128),
@V_FILE_NAME VARCHAR (128),
@V_COUNT BIGINT
AS
BEGIN
SET NOCOUNT ON
set @tmpVar = 0
/* DO_LOG ('start DO_CUSTOMERS_DAILY')
DO_LOG('END DO_CUSTOMERS_DAILY'),
DO_LOG('Start EXPORT DO_CUSTOMERS_DAILY')*/
SET @V_DIRECTORY = 'TBEX_DIR_DAILY'
SET @V_FILE_NAME = 'in_customer.txt'
SET @V_SQL_TMP =
'bcp
"SELECT INSTITUTE,
lpad(CUSTNO,16) CUSTNO,
rpad(NVL(FIRSTNAME, ''.''),32) FIRSTNAME,
rpad(NVL(LASTNAME, ''.''),32) LASTNAME,
rpad(NVL(STREET,'' ''),32) STREET,
rpad(NVL(ZIP,'' ''),7) ZIP,
rpad(NVL(TOWN,'' ''),28) TOWN,
rpad(NVL(H_COUNTRY,'' ''),3) H_COUNTRY,
rpad(NVL(S_COUNTRY,'' ''),3) S_COUNTRY,
rpad(NVL(CUSY,'' ''),8) CUSY,
rpad(NVL(FK_CSMNO,'' ''),12) FK_CSMNO,
rpad(NVL(PROFESSION,'' ''),32) PROFESSION,
rpad(NVL(BRANCH,'' ''),32) BRANCH,
rpad(NVL(BIRTHDATE,'' ''),8) BIRTHDATE,
rpad(NVL(CUSTCONTACT,'' ''),8) CUSTCONTACT,
NVL(EXEMPTIONFLAG,'' ''),
lpad(NVL(EXEMPTIONAMOUNT,'' ''),11) EXEMPTIONAMOUNT,
NVL(ASYLSYN,'' '') ASYLSYN,
lpad(NVL(SALARY,''0''),17) SALARY,
rpad(NVL(SALARYDATE,'' ''),8) SALARYDATE,
rpad(NVL(NAT_COUNTRY,'' ''),3) NAT_COUNTRY,
lpad(NVL(TOT_WEALTH,'' ''),17) TOT_WEALTH,
lpad(NVL(PROP_WEALTH,'' ''),3) PROP_WEALTH,
rpad(NVL(BRANCH_OFFICE,'' ''),10) BRANCH_OFFICE,
NVL(CUST_TYPE,'' '') CUST_TYPE,
lpad(NVL(CUST_FLAG_01,'' ''),1) CUST_FLAG_01,
lpad(NVL(CUST_FLAG_02,'' ''),1) CUST_FLAG_02,
lpad(NVL(CUST_FLAG_03,'' ''),1) CUST_FLAG_03,
lpad(NVL(CUST_FLAG_04,'' ''),1) CUST_FLAG_04,
lpad(NVL(CUST_FLAG_05,'' ''),1) CUST_FLAG_05,
lpad(NVL(CUST_FLAG_05,'' ''),1) CUST_FLAG_06,
lpad(NVL(CUST_FLAG_05,'' ''),1) CUST_FLAG_07,
lpad(NVL(CUST_FLAG_05,'' ''),1) CUST_FLAG_08,
lpad(NVL(CUST_FLAG_05,'' ''),1) CUST_FLAG_09,
lpad(NVL(CUST_FLAG_05,'' ''),1) CUST_FLAG_10,
lpad(NVL(CUST_FLAG_05,'' ''),1) CUST_FLAG_11,
lpad(NVL(CUST_FLAG_05,'' ''),12) CUST_FLAG_12,
lpad(NVL(CUST_FLAG_24,'' ''),1) CUST_FLAG_24,
rpad(NVL(EMPLNO,'' ''),16) EMPLNO,
rpad(NVL(PASS_NO,'' ''),17) PASS_NO,
rpad(NVL(BIRTH_COUNTRY,'' ''),3) BIRTH_COUNTRY,
lpad(NVL(BIRTH_PLACE,'' ''),32) BIRTH_PLACE,
NVL(BORROWERYN,'' '') BORROWERYN,
NVL(DIRECT_DEBITYN,'' '') DIRECT_DEBITYN,
NVL(GENDER,'' '') GENDER,
rpad(NVL(RISK_CLASS,'' ''),10) RISK_CLASS
FROM TB_CUSTOMERS_DAILY
ORDER BY lpad(CUSTNO,16)"
queryout "C:\in_customer" -c -T
-- DO_LOG(V_SQL_TMP),
--DUMP_EXPORT_DATA ( V_SQL_TMP, V_DIRECTORY, V_FILE_NAME,V_COUNT),
--DO_LOG(End EXPORT DO_CUSTOMERS_DAILY),
/* BEGIN TRY
WHEN NO_DATA_FOUND THEN
NULL,
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE, */
END
我已在SQL Server 2012中创建此过程。我的预期输出是在执行后,它会创建文本文件。但它不起作用。如果你不介意,请检查我的DO_LOG查询。 如果您有任何建议,请给我一些。提前谢谢你 这个页面有时会让我恼火