Can you reference 'Inserted' or 'Deleted' Trigger Table in SQL Mail Query

  • Hello,

    I am trying to reference the results from the Inserted or Deleted tables from a SQL Trigger in teh @query param of sp_sendmail but doesn't seem to work.  Getting the dreaded: Msg 22050, Level 16, State 1, Line 54

    Failed to initialize sqlcmd library with error number -2147467259. This usually happens when you are not using a fully qualified table.  You need to include the database but no matter how I write the query, even when making as basic as possible doesn't seem to be able to access it.  Any suggestions besides dumping the results from Inserted and Deleted to a real table and then referencing it in the @Query param for sp_Sendmail?

     

    Thanks,

     

    Daniel

  • The inserted and deleted "tables" only exist within the direct code of a trigger.  You can't reference them from an external query.  You'd need to write the inserted and deleted rows to an actual table(s) to reference them in any external query.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

  • Figured.  Thank you.

  • This was removed by the editor as SPAM

  • This was removed by the editor as SPAM

  • This was removed by the editor as SPAM

Viewing 6 posts - 1 through 5 (of 5 total)

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