Timeout Expired

  • I fire a trigger on tblAdmin

    as

    CREATE TRIGGER [dbo].[trg_mailupdation]

    ON [dbo].[tblAdmin]

    After UPDATE

    AS

    BEGIN

    -- SET NOCOUNT ON added to prevent extra result sets from

    -- interfering with SELECT statements.

    SET NOCOUNT ON;

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'crm',

    @recipients = 'umashankar@gmail.com',

    @body_format = 'HTML',

    @query = 'select adminname,resposibility1,mailid from customer.dbo.tblAdmin' ,

    @subject = 'Admin Update Details',

    @attach_query_result_as_file = 1;

    END

    Now when I execute select *from tblAdmin

    Timeout Expired error occured.

    Nither this trigger deleted nor disable.

    What are causes?

    Please help.........

    Thanks.......
    -----------------------------------
    My Blog[/url] | Articles

  • Do you realize you're sending the whole tbladmin in your email?

    Triggers use inserted and deleted tables and your query is not specifying any of them

    select adminname,resposibility1,mailid from customer.dbo.tblAdmin

    you should change it to

    select adminname,resposibility1,mailid from customer.dbo.tblAdmin ta inner join inserted i on ta.your key = i.yourkey

    that will give you the new updated record.

    Plus it's bad practice to include sp_send_dbmail inside a trigger. if the mail server stalls you're ()#&%(#^%.

    Alex S

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

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