• you cannot append values, or assign variables to the parameters in line:

    --not allowed

    @subject ='Number of unprocessed records on SQL1 ' + cast(@recordcount as varchar(10));

    --the replacement

    DECLARE @mysubject varchar(500) = 'Number of unprocessed records on SQL1 ' + cast(@recordcount as varchar(10));

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'DBA_Mail',

    @recipients = 'paresh.motiwala@gmail.com',

    @body = 'The count of the unprocessed records.',

    --assign the parameter to a variable that did the work

    @subject = @mysubject

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!