I need to remove "Rows affected from query in send mail"

  • Hi I need to remove "rows affected" text from results as shown below from posted Sp. i am using set nocount on but its not working as expected.

    Create Procedure DailyCheckList

    As

    SET NOCOUNT ON

    Declare @EmailSub varchar(500),@dt varchar(100),@Msg varchar(max),@M varchar(max)

    set @dt= convert(varchar(20),GETDATE(),107)

    Set @EmailSub='Daily Checklist for '+ @dt

    exec msdb..sp_send_dbmail

    @Profile_name = 'XXX',

    @recipients ='XXX',

    @subject =@emailSub ,

    @Body = @Msg , ------@ReturnMessage

    @query = 'select * from [DailyCheck_DiskSpace]; Select * from [dbo].[DailyCheckFailover]; select * from [dbo].[DailyCheckFailedJobs]' ,

    @body_format = 'HTML'

    Sagar Sonawane
    ** Every DBA has his day!!:cool:

  • Use SET NOCOUNT ON in the database mail query:

    Create Procedure DailyCheckList

    As

    SET NOCOUNT ON

    Declare @EmailSub varchar(500),@dt varchar(100),@Msg varchar(max),@M varchar(max)

    set @dt= convert(varchar(20),GETDATE(),107)

    Set @EmailSub='Daily Checklist for '+ @dt

    exec msdb..sp_send_dbmail

    @Profile_name = 'XXX',

    @recipients ='XXX',

    @subject =@emailSub ,

    @Body = @Msg , ------@ReturnMessage

    @query = 'SET NOCOUNT ON;select * from [DailyCheck_DiskSpace]; Select * from [dbo].[DailyCheckFailover]; select * from [dbo].[DailyCheckFailedJobs]' ,

    @body_format = 'HTML'

    -- Gianluca Sartori

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply