SQL Server 2005 sp_send_dbmail

  • 13 years ago

    Hi
    I'm experiencing problems with the @query parameter in the sp_send_dbmail SP (SQL Server 2005).

    Using the following code:
    exec msdb.dbo.sp_send_dbmaill
    @profile_name='SQL2005Profile',
    @recipients='[email protected]',
    @body='Test Message',
    @subject='URGENT!!!!',
    @query='Select * From Table_1'

    If i run the above code as a SQL Query it works fine, but when I add it into a trigger it always crashes causing the process to be suspended, showing the last statement as "Select * From table_1'. In order to regain control of program the process has to be killed.

    Code for Trigger:
    Create triger dbo.update_table_1
    On dbo.table_1
    After Update
    As
    If Update(col_3)
    Begin
    Set NOCount ON;
    exec msdb.dbo.sp_send_dbmaill
    @profile_name='SQL2005Profile',
    @recipients='[email protected]',
    @body='Test Message',
    @subject='URGENT!!!!',
    @query='Select * From Table_1'
    End




























    There is no record in any of msdb.dbo.sysmail_....... views to show that mail has failed.


    Does anyone know why this is happening? (Login Account has full administrative permissions)

    Thanks in advance


Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There's no test like production” - Anon