GET-IT: TEAMS DAY | 1-Day Free Virtual Conference all about Teams. Here on Petri.com - 8/12/20 GET-IT: TEAMS DAY - 8/12/20

Condition for Not to Send Mail

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #165295

    Hi,

    I am using below condition for sending mail from SQL Server, but i want add the condition for not to send mail “IF (@A1SQL IS NULL )”

    can someone provide the code part for that?

    — Condition for Send Mail

    [HTML]SET @A1SQL = N’select * from Tablename’;

    IF (@A1SQL IS NOT NULL )
    BEGIN

    SET @tableHTML =

    N’

    details

    ‘ +

    N’

    ‘ +
    N’

    ‘ +
    N’

    ‘ +

    CAST ( ( SELECT “td/@align” = ‘right’, td = createdate, ”,
    “td/@align” = ‘right’, td = dbname, ”

    FROM TableName

    FOR XML PATH(‘tr’), TYPE

    ) AS NVARCHAR(MAX) ) +

    N’

    createdate dbname

    ‘ ;

    EXEC MSDB.DBO.SP_SEND_DBMAIL
    @profile_name=’xxxx’,
    @recipients=’xxxxx’,
    @subject =’ details ‘ ,
    @body = @tableHTML,
    @body_format =’HTML’
    end[/HTML]

    thanks.

    [MOD EDIT – hyperlink to commercial (spam) site removed and warning issued. Next time WILL be a ban]
    [MOD EDIT 2 – “Next time” was in the user profile…. bye, bye :evil:]

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.