using temp tables with xp_sendmail

  • Hi there

    How can I use temp tables with xp_sendmail e.g. I have a temptable called #email and then I want to execute: xp_sendmail @query = 'select * from #email', but I get the error: Invalid object #email.

    Please help, SQL guru's

    Cheers


    Reach for the stars, not the ceiling...

  • The problem might be the scope of the temp table. xp_sendmail runs from the master database whereas you are executing the proc from your user database and the temp table might not be 'visible' in the master db.

    Try making the temp table a global temp table by calling it ##email.

    Jeremy

  • Thanks. I'll give it a go

    Reach for the stars, not the ceiling...


    Reach for the stars, not the ceiling...

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

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