Sunday, February 5, 2017

Data Driven Subscriptions


Step 1


Step 2


Step 3


Code - Output ( Daily Buffer Report as at 05-Feb-2017)
ReportName with DD-MON-YYYY

SELECT
'Daily Buffer Report as at ' +
              REPLACE
            (
                CONVERT(VARCHAR(11), GETDATE()-1, 106),
               ' ',
              '-'
           )

AS [EmailSubject]


Case study

Lets assume that you have a list of plants and each plant should get data specific to them only. Plant QLD should get a report having QLD plant related data.

Example:

PlantDDSEmails Table for Data Driven Subscription
Plant
Email
QLD qld@gmail.com
VIC
vic@gmail.com
NSW
nsw@gmail.com

Code

SELECT Email,Plant,

'QLD Debtors Dashboard as at '+
REPLACE
CONVERT(VARCHAR(11), GETDATE()-1, 106),
' ', 
'-' 
) as [EmailSubject] 
FROM dbo.PlantDDSEmails where Plant='QLD'

OR


SELECT 
 ( select plant +' Debtors Dashboard as at ' from dbo.PlantDDSEmails 
  where Plant ='QLD'
 ) +
REPLACE  
(
     CONVERT(VARCHAR(11), GETDATE()-1, 106),
     ' ', 
     '-' 
)AS [EmailSubject]

Step 4




Step 5




Step 6




Step 7



Step 8

Click Finish button.

Thanks & Cheers :)
Thilini

No comments:

Post a Comment