M
Mike C
I have a fairly long SQL string that I'd like to wrap since I can't fit in a
single line. I'm not sure how to do it, any help would be greatly appreciated.
SELECT SUBSTRING(TLDSEU_CUR.OUB_SRT_DT,5,2) + '/' +
SUBSTRING(TLDSEU_CUR.OUB_SRT_DT,7,2) + '/' +
SUBSTRING(TLDSEU_CUR.OUB_SRT_DT,1,4) AS Sort_Date, [TLDSEU_CUR].ULO_NR AS
Trailer, SUBSTRING(TLDSEU_CUR.ORG_OGZ_NR,2,4) + ' ' +
TTYPSRT_DCO.SRT_TYP_MNM_TE AS Origin, TLDSEU_CUR.DTN_CNY_CD + ' ' +
SUBSTRING(TLDSEU_CUR.DTN_OGZ_NR,2,4) + ' ' + TTYPSRT_DCO_1.SRT_TYP_MNM_TE + '
' + TTYPSVC_DCO.SVC_TYP_MNM_TE AS Destination, [TLDSEU_CUR].BLT_NR,
[TLDSEU_CUR].BAY_NR,RTRIM(SUBSTRING(TULOLNK_DCO.ULO_LNK_SN_SHT_TE,1,1) +
LOWER(SUBSTRING(TULOLNK_DCO.ULO_LNK_SN_SHT_TE,2,15)) ) AS [Scan Type],
/*( SELECT COUNT(TULO.LD_PKG_QY) FROM TOUOWSN_CUR AS SCAN INNER JOIN
TLDSEU_CUR AS TULO ON SCAN.LD_REF_NR = TULO.LD_REF_NR
WHERE( (SCAN.UOW_TYP_CD = '02') AND (TULO.ULO_NR =TLDSEU_CUR.ULO_NR) AND
(TOUOWSN_CUR.SRT_TYP_CD = SCAN.SRT_TYP_CD) AND (TLDSEU_CUR.OUB_SRT_DT =
TULO.OUB_SRT_DT) AND (TLDSEU_CUR.ORG_OGZ_NR = TULO.ORG_OGZ_NR))) AS Pkgs,*/
( SELECT COUNT(TULO.LD_BAG_QY) FROM TOUOWSN_CUR AS SCAN INNER JOIN
TLDSEU_CUR AS TULO ON SCAN.LD_REF_NR = TULO.LD_REF_NR
WHERE( (SCAN.UOW_TYP_CD = '04') AND (TULO.ULO_NR =TLDSEU_CUR.ULO_NR) AND
(TOUOWSN_CUR.SRT_TYP_CD = SCAN.SRT_TYP_CD) AND (TLDSEU_CUR.OUB_SRT_DT =
TULO.OUB_SRT_DT) AND (TLDSEU_CUR.ORG_OGZ_NR = TULO.ORG_OGZ_NR) AND
(TLDSEU_CUR.BLT_NR = TULO.BLT_NR) AND (TLDSEU_CUR.BAY_NR = TULO.BAY_NR) ))
AS Bags, COUNT( TOUOWSN_CUR.UOW_TYP_CD
) AS Pkgs, DATEADD ( hh , (DATEDIFF ( hh , GetUTCDate(), GetDate() ))
,MAX(TOUOWSN_CUR.PKL_SN_ACT_TS )) AS Last_Local_Scan_Time, ( SELECT TOP 1
SCAN.PKG_TCK_NR FROM TOUOWSN_CUR AS SCAN INNER JOIN TLDSEU_CUR AS TULO ON
SCAN.LD_REF_NR = TULO.LD_REF_NR WHERE( (SCAN.PKL_SN_ACT_TS =
MAX(TOUOWSN_CUR.PKL_SN_ACT_TS) ) AND (SCAN.UOW_TYP_CD = '02') AND
(TULO.ULO_NR =TLDSEU_CUR.ULO_NR) AND (TOUOWSN_CUR.SRT_TYP_CD =
SCAN.SRT_TYP_CD) AND (TLDSEU_CUR.OUB_SRT_DT = TULO.OUB_SRT_DT) AND
(TLDSEU_CUR.ORG_OGZ_NR = TULO.ORG_OGZ_NR))) AS Last_Package,
SUBSTRING(TLDSEU_CUR.LD_CRT_DT,5,2) + '/' +
SUBSTRING(TLDSEU_CUR.LD_CRT_DT,7,2) + '/' +
SUBSTRING(TLDSEU_CUR.LD_CRT_DT,1,4) AS Load_Create_Date FROM TTYPSRT_DCO AS
TTYPSRT_DCO_1 INNER JOIN (TULOLNK_DCO INNER JOIN (TTYPSVC_DCO INNER JOIN
((TOUOWSN_CUR INNER JOIN TTYPSRT_DCO ON TOUOWSN_CUR.SRT_TYP_CD =
TTYPSRT_DCO.SRT_TYP_CD) INNER JOIN TLDSEU_CUR ON TOUOWSN_CUR.LD_REF_NR =
TLDSEU_CUR.LD_REF_NR) ON TTYPSVC_DCO.SVC_TYP_CD = TLDSEU_CUR.SVC_TYP_CD) ON
TULOLNK_DCO.ULO_LNK_SN_CD = TLDSEU_CUR.ULO_LNK_SN_CD) ON
TTYPSRT_DCO_1.SRT_TYP_CD = TLDSEU_CUR.DTN_SRT_TYP_CD WHERE
((([TLDSEU_CUR].ULO_TYP_CD)='04') AND ((TOUOWSN_CUR.UOW_TYP_CD) = '02')
AND ((tldseu_cur.OUB_SRT_DT) = '20071004')) GROUP BY
SUBSTRING(TLDSEU_CUR.OUB_SRT_DT,5,2) + '/' +
SUBSTRING(TLDSEU_CUR.OUB_SRT_DT,7,2) + '/' +
SUBSTRING(TLDSEU_CUR.OUB_SRT_DT,1,4) , [TLDSEU_CUR].ULO_NR,
SUBSTRING(TLDSEU_CUR.ORG_OGZ_NR,2,4) + ' ' + TTYPSRT_DCO.SRT_TYP_MNM_TE ,
TLDSEU_CUR.DTN_CNY_CD + ' ' + SUBSTRING(TLDSEU_CUR.DTN_OGZ_NR,2,4) + ' ' +
TTYPSRT_DCO_1.SRT_TYP_MNM_TE + ' ' + TTYPSVC_DCO.SVC_TYP_MNM_TE ,
[TLDSEU_CUR].BLT_NR, [TLDSEU_CUR].BAY_NR,
RTRIM(SUBSTRING(TULOLNK_DCO.ULO_LNK_SN_SHT_TE,1,1) +
LOWER(SUBSTRING(TULOLNK_DCO.ULO_LNK_SN_SHT_TE,2,15)) ) ,
TOUOWSN_CUR.SRT_TYP_CD,TLDSEU_CUR.ORG_OGZ_NR,TLDSEU_CUR.OUB_SRT_DT,TLDSEU_CUR.LD_CRT_DT;
single line. I'm not sure how to do it, any help would be greatly appreciated.
SELECT SUBSTRING(TLDSEU_CUR.OUB_SRT_DT,5,2) + '/' +
SUBSTRING(TLDSEU_CUR.OUB_SRT_DT,7,2) + '/' +
SUBSTRING(TLDSEU_CUR.OUB_SRT_DT,1,4) AS Sort_Date, [TLDSEU_CUR].ULO_NR AS
Trailer, SUBSTRING(TLDSEU_CUR.ORG_OGZ_NR,2,4) + ' ' +
TTYPSRT_DCO.SRT_TYP_MNM_TE AS Origin, TLDSEU_CUR.DTN_CNY_CD + ' ' +
SUBSTRING(TLDSEU_CUR.DTN_OGZ_NR,2,4) + ' ' + TTYPSRT_DCO_1.SRT_TYP_MNM_TE + '
' + TTYPSVC_DCO.SVC_TYP_MNM_TE AS Destination, [TLDSEU_CUR].BLT_NR,
[TLDSEU_CUR].BAY_NR,RTRIM(SUBSTRING(TULOLNK_DCO.ULO_LNK_SN_SHT_TE,1,1) +
LOWER(SUBSTRING(TULOLNK_DCO.ULO_LNK_SN_SHT_TE,2,15)) ) AS [Scan Type],
/*( SELECT COUNT(TULO.LD_PKG_QY) FROM TOUOWSN_CUR AS SCAN INNER JOIN
TLDSEU_CUR AS TULO ON SCAN.LD_REF_NR = TULO.LD_REF_NR
WHERE( (SCAN.UOW_TYP_CD = '02') AND (TULO.ULO_NR =TLDSEU_CUR.ULO_NR) AND
(TOUOWSN_CUR.SRT_TYP_CD = SCAN.SRT_TYP_CD) AND (TLDSEU_CUR.OUB_SRT_DT =
TULO.OUB_SRT_DT) AND (TLDSEU_CUR.ORG_OGZ_NR = TULO.ORG_OGZ_NR))) AS Pkgs,*/
( SELECT COUNT(TULO.LD_BAG_QY) FROM TOUOWSN_CUR AS SCAN INNER JOIN
TLDSEU_CUR AS TULO ON SCAN.LD_REF_NR = TULO.LD_REF_NR
WHERE( (SCAN.UOW_TYP_CD = '04') AND (TULO.ULO_NR =TLDSEU_CUR.ULO_NR) AND
(TOUOWSN_CUR.SRT_TYP_CD = SCAN.SRT_TYP_CD) AND (TLDSEU_CUR.OUB_SRT_DT =
TULO.OUB_SRT_DT) AND (TLDSEU_CUR.ORG_OGZ_NR = TULO.ORG_OGZ_NR) AND
(TLDSEU_CUR.BLT_NR = TULO.BLT_NR) AND (TLDSEU_CUR.BAY_NR = TULO.BAY_NR) ))
AS Bags, COUNT( TOUOWSN_CUR.UOW_TYP_CD
) AS Pkgs, DATEADD ( hh , (DATEDIFF ( hh , GetUTCDate(), GetDate() ))
,MAX(TOUOWSN_CUR.PKL_SN_ACT_TS )) AS Last_Local_Scan_Time, ( SELECT TOP 1
SCAN.PKG_TCK_NR FROM TOUOWSN_CUR AS SCAN INNER JOIN TLDSEU_CUR AS TULO ON
SCAN.LD_REF_NR = TULO.LD_REF_NR WHERE( (SCAN.PKL_SN_ACT_TS =
MAX(TOUOWSN_CUR.PKL_SN_ACT_TS) ) AND (SCAN.UOW_TYP_CD = '02') AND
(TULO.ULO_NR =TLDSEU_CUR.ULO_NR) AND (TOUOWSN_CUR.SRT_TYP_CD =
SCAN.SRT_TYP_CD) AND (TLDSEU_CUR.OUB_SRT_DT = TULO.OUB_SRT_DT) AND
(TLDSEU_CUR.ORG_OGZ_NR = TULO.ORG_OGZ_NR))) AS Last_Package,
SUBSTRING(TLDSEU_CUR.LD_CRT_DT,5,2) + '/' +
SUBSTRING(TLDSEU_CUR.LD_CRT_DT,7,2) + '/' +
SUBSTRING(TLDSEU_CUR.LD_CRT_DT,1,4) AS Load_Create_Date FROM TTYPSRT_DCO AS
TTYPSRT_DCO_1 INNER JOIN (TULOLNK_DCO INNER JOIN (TTYPSVC_DCO INNER JOIN
((TOUOWSN_CUR INNER JOIN TTYPSRT_DCO ON TOUOWSN_CUR.SRT_TYP_CD =
TTYPSRT_DCO.SRT_TYP_CD) INNER JOIN TLDSEU_CUR ON TOUOWSN_CUR.LD_REF_NR =
TLDSEU_CUR.LD_REF_NR) ON TTYPSVC_DCO.SVC_TYP_CD = TLDSEU_CUR.SVC_TYP_CD) ON
TULOLNK_DCO.ULO_LNK_SN_CD = TLDSEU_CUR.ULO_LNK_SN_CD) ON
TTYPSRT_DCO_1.SRT_TYP_CD = TLDSEU_CUR.DTN_SRT_TYP_CD WHERE
((([TLDSEU_CUR].ULO_TYP_CD)='04') AND ((TOUOWSN_CUR.UOW_TYP_CD) = '02')
AND ((tldseu_cur.OUB_SRT_DT) = '20071004')) GROUP BY
SUBSTRING(TLDSEU_CUR.OUB_SRT_DT,5,2) + '/' +
SUBSTRING(TLDSEU_CUR.OUB_SRT_DT,7,2) + '/' +
SUBSTRING(TLDSEU_CUR.OUB_SRT_DT,1,4) , [TLDSEU_CUR].ULO_NR,
SUBSTRING(TLDSEU_CUR.ORG_OGZ_NR,2,4) + ' ' + TTYPSRT_DCO.SRT_TYP_MNM_TE ,
TLDSEU_CUR.DTN_CNY_CD + ' ' + SUBSTRING(TLDSEU_CUR.DTN_OGZ_NR,2,4) + ' ' +
TTYPSRT_DCO_1.SRT_TYP_MNM_TE + ' ' + TTYPSVC_DCO.SVC_TYP_MNM_TE ,
[TLDSEU_CUR].BLT_NR, [TLDSEU_CUR].BAY_NR,
RTRIM(SUBSTRING(TULOLNK_DCO.ULO_LNK_SN_SHT_TE,1,1) +
LOWER(SUBSTRING(TULOLNK_DCO.ULO_LNK_SN_SHT_TE,2,15)) ) ,
TOUOWSN_CUR.SRT_TYP_CD,TLDSEU_CUR.ORG_OGZ_NR,TLDSEU_CUR.OUB_SRT_DT,TLDSEU_CUR.LD_CRT_DT;