I have a sql job which runs once every 24 hours and sends an email with the data requested from my database tables. I'm inserting the data into :
DECLARE @ReportContentBuilder table(LineSequence int identity, Line varchar(2000))
Like so :
INSERT INTO @ReportContentBuilder VALUES('<html>')
INSERT INTO @ReportContentBuilder VALUES('<head>')
INSERT INTO @ReportContentBuilder VALUES('<style type="text/css">')
INSERT INTO @ReportContentBuilder VALUES('body{font-family: Calibri; font-size: 10pt;}')
INSERT INTO @ReportContentBuilder VALUES('</style>')
INSERT INTO @ReportContentBuilder VALUES('</head>')
INSERT INTO @ReportContentBuilder VALUES('<body>')
Which is all good the email is sent and I receive all the data as expected. Its just my table headings are all the same.
WHILE (@MessageTypeCount > 0)
BEGIN
-- SET a parameter here to use as Id
INSERT INTO @ReportContentBuilder VALUES('<table cellpadding="2" border="1">')
INSERT INTO @ReportContentBuilder VALUES('<caption><b>Id</b></caption>')
-- Etc. etc. all the rest of the code works
END
I have a While loop and want to pass in a parameter into the Id section so the table heading will be different for each loop.
Question:
How do I pass a value into the Html part of the code to receive different table headings in my email?
I hope this is clear and I've added enough info.