我们可以避免在从sql查询通过ssis导出日期时在txt文件末尾获得一个空行吗?

时间:2016-08-03 18:58:35

标签: sql ssis

我的场景:我有一个场景,我需要使用SSIS生成一个文本制表符分隔文件,源数据来自SQL查询。

问题:我生成了文本干净的文本文件,但是我在文件的末尾得到一个空行,我需要删除该行,我检查了我的sql查询结果,其中没有空行。任何人都可以建议我该怎么办?

来源查询:

SELECT  
    CASE 
              WHEN DATEPART(WEEKDAY,GETDATE()) = 2 THEN LTRIM(RTRIM(CONVERT(DATE,DATEADD(D,-3,GETDATE()),126)))
              WHEN DATEPART(WEEKDAY,GETDATE()) = 3 THEN LTRIM(RTRIM(CONVERT(DATE,DATEADD(D,-1,GETDATE()),126)))
              WHEN DATEPART(WEEKDAY,GETDATE()) = 4 THEN LTRIM(RTRIM(CONVERT(DATE,DATEADD(D,-1,GETDATE()),126)))
              WHEN DATEPART(WEEKDAY,GETDATE()) = 5 THEN LTRIM(RTRIM(CONVERT(DATE,DATEADD(D,-1,GETDATE()),126)))
              WHEN DATEPART(WEEKDAY,GETDATE()) = 6 THEN LTRIM(RTRIM(CONVERT(DATE,DATEADD(D,-1,GETDATE()),126)))
            ELSE ''
          END AS [COB Date],
     LTRIM(RTRIM('1802'))  AS Branch,
     LTRIM(RTRIM(CIF)) AS [Client Id],
     LTRIM(RTRIM(CRM.[Limit ID])) AS [LIMIT ID],
     LTRIM(RTRIM([TRANSACTION])) AS [Account Id],
     CASE [DEMAND-TERM] WHEN 'DEMAND' THEN LTRIM(RTRIM('316')) ELSE LTRIM(RTRIM('319'))  END AS [Account Type],
     LTRIM(RTRIM(CONVERT(DATE,CRM.[Start Date]))) AS  [Start Date],
     CASE WHEN LTRIM(RTRIM(LD.[TRANSACTION])) LIKE ('1%') THEN 
                                              CASE 
                                     WHEN  LTRIM(RTRIM(CRM.[Expiry Date])) = '22220222' AND DATEPART(WEEKDAY,GETDATE()) = 2 OR CRM.[Expiry Date] = '' THEN LTRIM(RTRIM(DATEADD(DAY,1,CONVERT(DATE,GETDATE()))))
                                     WHEN  LTRIM(RTRIM(CRM.[Expiry Date])) = '22220222' AND DATEPART(WEEKDAY,GETDATE()) = 3 OR CRM.[Expiry Date] = '' THEN LTRIM(RTRIM(DATEADD(DAY,1,CONVERT(DATE,GETDATE()))))
                                     WHEN  LTRIM(RTRIM(CRM.[Expiry Date])) = '22220222' AND DATEPART(WEEKDAY,GETDATE()) = 4 OR CRM.[Expiry Date] = '' THEN LTRIM(RTRIM(DATEADD(DAY,1,CONVERT(DATE,GETDATE()))))
                                     WHEN  LTRIM(RTRIM(CRM.[Expiry Date])) = '22220222' AND DATEPART(WEEKDAY,GETDATE()) = 5 OR CRM.[Expiry Date] = '' THEN LTRIM(RTRIM(DATEADD(DAY,1,CONVERT(DATE,GETDATE()))))
                                     WHEN  LTRIM(RTRIM(CRM.[Expiry Date])) = '22220222' AND DATEPART(WEEKDAY,GETDATE()) = 6 OR CRM.[Expiry Date] = '' THEN LTRIM(RTRIM(DATEADD(DAY,3,CONVERT(DATE,GETDATE()))))
                                     WHEN  LTRIM(RTRIM(CRM.[Expiry Date])) = '22220222' AND DATEPART(WEEKDAY,GETDATE()) = 7 OR CRM.[Expiry Date] = '' THEN LTRIM(RTRIM(DATEADD(DAY,2,CONVERT(DATE,GETDATE()))))
                                     WHEN  LTRIM(RTRIM(CRM.[Expiry Date])) = '22220222' AND DATEPART(WEEKDAY,GETDATE()) = 1 OR CRM.[Expiry Date] = '' THEN LTRIM(RTRIM(DATEADD(DAY,1,CONVERT(DATE,GETDATE())))) 
                                ELSE CONVERT(DATE,CRM.[Expiry Date]) END ELSE LTRIM(RTRIM(CONVERT(DATE,LD.[OUTSTANDING-MATURITY-DATE]))) END AS [Maturity Date],
     LTRIM(RTRIM(CCY)) AS [Account Currency],
     LTRIM(RTRIM(OUTSTANDING)) AS [Amount],
     LTRIM(RTRIM('D')) AS [Debit Credit],
     CASE  WHEN [CIF] = '100665' THEN LTRIM(RTRIM('286')) ELSE LTRIM(RTRIM('285')) END AS [Product Code]    
FROM  [LOAN.DETAIL] LD
LEFT JOIN t_CRM_MONTHLY_RPT_NY CRM
ON LD.[LIMIT-ID] = CRM.[Limit ID]
WHERE ([RM-AREA] = 'UHNN')

目标文件: enter image description here

我只需要49行而不是50行。 我怎么能这样做?

0 个答案:

没有答案