Enter working in business intelligence. Now the data matters and the format it is delivered in. The learning curve for me has been steep; I have always been more focused on content than aesthetics. Now both are a requirement. Initially, I thought this was silly but I am starting to understand the importance of things being right and looking good. Alerts, reports, etc will be used and paid attention to when they have the proper coloring and gradients to express what the data is saying. Just dumping numbers to the screen will not suffice anymore. In addition, the obvious mobile device usage in this day and age predicates that the alerts look good on a mobile phone as well.
The process is brute force HTML construction, but it yields a pretty nice looking alert and does not require outright looping or much code. Essentially, you construct a style sheet and then use a few TSQL tricks to generate the data set and create ladderstriping with Row_number() functions. (yet another term I was unfamiliar with until BI). I would not call the process graceful, but it passes the eye test with the very picky data consumers I have :).
DECLARE @Alert NVARCHAR(MAX) = '' +
SELECT @Alert = coalesce(@Alert,'') +
+ '">' +
WHERE alertProblem=1 )
DECLARE @rc INT = @@ROWCOUNT
SELECT @Alert += N'
IF(@rc > 0 AND @Alert IS NOT NULL)
DECLARE @MailProfile VARCHAR(255) = 'mailprofile'
DECLARE @subj varchar(128) = @@SERVERNAME + ': DataAlertName'
DECLARE @FromAddress varchar(128) = @FromAddress
@from_address = @FromAddress
,@reply_to = @FromAddress
,@recipients = @email
,@body = @Alert
,@subject = @subj
,@profile_name = @MailProfile
,@body_format = 'HTML' ;
Looking forward to trying one of these out for fixing fences and hauling rocks this spring.