All2Cheesy
Board Regular
- Joined
- Mar 4, 2015
- Messages
- 127
Hello all,
I'm looking to enter the below query from a sql server database. However, in the Enter Connotes section, rather than entering in a list of connotes into the code, I would like for it to refer to a list of connotes in the excel workbook.
I would appreciate it if someone could advise me on the best way to go about this. Thanks in advance.
I'm looking to enter the below query from a sql server database. However, in the Enter Connotes section, rather than entering in a list of connotes into the code, I would like for it to refer to a list of connotes in the excel workbook.
I would appreciate it if someone could advise me on the best way to go about this. Thanks in advance.
SQL:
SELECT
REPLACE(REPLACE(IV.fldFreightMode,2,'BEB'),4,'BEP') AS ServiceType
,IV.fldInvoiceNumber AS ConNoteNumber
,'' AS ReceiverCode
,ISNULL(IV.fldSenderReference,'') AS SenderReference
,ISNULL(IV.fldReceiverReference,'') AS ReceiverReference
,ISNULL(ISNULL(AG.fldTradingName, AG.fldLegalName), RC.[Sending Centre]) AS fldOnfwdRcvBranch
,REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(ISNULL(IV.fldReceiverName ,''),CHAR(13)+CHAR(10),''),CHAR(9),''),CHAR(10),''),CHAR(13),''),'"','') AS Receiver
,RS.Suburb AS ReceiverSuburb
,IV.fldReceiverState AS ReceiverState
,IV.fldReceiverPostcode AS ReceiverPostcode
,CONVERT(DATE,IV.fldInvoiceDate,103) AS DespatchDate
,CONVERT(DATE,IV.fldETADate,103) AS ETADate
,'' AS ReleaseDate -- @ReleaseDate AS ReleaseDate
,ISNULL((SELECT CONVERT(NVARCHAR(10),MAX(POD.fldDateSigned),103) FROM TS2000.vwPOD POD WITH(NOLOCK) WHERE POD.fldInvoiceNumber = IV.fldInvoiceNumber),'') AS DeliveryDate
,ISNULL((SELECT TOP 1 fldNameSigned FROM TS2000.fncPODValidRank(IV.fldInvoiceNumber) WHERE fldNameSigned IS NOT NULL),'') AS ReceivedBy
,(SELECT (Case When fldBEXOnlineText = 'Delivered' Then 'Complete' Else '' End) FROM TS2000.fncGetConsignmentStatus(IV.pkInvoice)) AS PODStatus
,(SELECT fldBEXOnlineText FROM TS2000.fncGetConsignmentStatus(IV.pkInvoice)) AS DeliveryDesc
FROM TS2000.vwInvoiceValid IV WITH(NOLOCK)
LEFT JOIN TS2000.syn_Suburbs RS WITH(NOLOCK) ON IV.fkReceiverSuburb = RS.ID
LEFT JOIN TS2000.vwAgentDetails AS AG WITH (NOLOCK) ON RS.fkAgent = AG.pkAgentId
LEFT JOIN TS2000.tblSuburbDepot RD WITH (NOLOCK) ON IV.fkReceiverSuburb = RD.fkSuburbID
LEFT JOIN TS2000.[Sending Centres] RC WITH (NOLOCK) ON RD.fkDepotID = RC.fldDepotID
WHERE RD.fldType = 'R' AND RD.fldOrder = 1
AND IV.fldInvoiceNumber IN (
-- Enter Connotes
*Refer to list of connotes in excel*
)
ORDER BY DespatchDate, ConNoteNumber