Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
christxavier
Starting Member
1 Post |
Posted - 2014-07-18 : 04:38:34
|
Hi,This is my stored procedure for sending email. It works fine. But how to check if condition inside html formatCREATE PROCEDURE [dbo].[Condition_Status] (@view nvarchar(30), @EMAIL CHAR(150)) ASDECLARE @tableHTML NVARCHAR(MAX) DECLARE @emailsubject char(150)SET @tableHTML =N'<BODY topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0" style=" "bgcolor="#ffffff">'+ N'<CENTER>'+N'<div align="center">' +N'<table cellpadding="0" cellspacing="0" width="820" bordercolor="#464646" style=" border-border-border-right: 1px solid #464646; border-bottom:2px solid #464646;">'+ N'<tr>'+ N'<td>'+N'<table cellpadding="0" cellspacing="0" width="820" bgcolor="#f3f3f3">'+N'<TR>' +N'<td colspan="3" align="center">' +// here i want to use if condition based on @view parameter. @view parameter i will be passing value from database. heading1 column is xxxheading2 column is yyyif @view contains xxx, i need to show heading1 and if @view contains yyy, i need to show heading2Right now i am showing heading1 column see below select coding. But dynamically i need to show according to @view parameter.N'<span style=font-size:17pt;font-family:Calibri;color:#4e4e4e;font-weight:bold;>'+cast((select isnull(heading1,'') from tab1 where email1=@EMAIL for xml path(''),type)as varchar(max)) +'</p>'+</span>' +N'</td>' +N'</TR>'+N'</TABLE>' +N'</td>'+N'</tr>'+N'</table>'+N'<div>'+N'</BODY>' select @tableHTML set @emailsubject = 'Test#'+ convert(char(8), @EMAIL) EXEC msdb.dbo.sp_send_dbmail @recipients = @EMAIL, @profile_name = 'gmail',@subject = @emailsubject, @body = @tableHTML,@body_format = 'HTML'christ |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2014-07-18 : 05:25:07
|
You can use a CASE statements to investigate your values. Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
|
|
|
|
|