Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sp_send_dbmail

Author  Topic 

tejicen
Starting Member

17 Posts

Posted - 2009-07-14 : 08:40:00
Hi,

why do i get this message?

(1 row(s) affected)
Msg 14661, Level 16, State 1, Procedure sp_send_dbmail, Line 476
Query execution failed: Msg 102, Level 15, State 1, Server MOBILLSRV06, Line 1
Incorrect syntax near '@tmpTbl'.

create proc [dbo].[EMAILINFO]
@inValue varchar(255)
as
begin
declare @tmpTbl table
(
value varchar(255)
)
insert into @tmpTbl
select value = @inValue

exec msdb.dbo.sp_send_dbmail
@profile_name = 'info',
@recipients = 'info@mobill.se',
@importance ='High',
@query = 'select * from databas.dbo.@tmpTbl',
@subject = 'TEST',
@query_attachment_filename ='Results.txt'
end

regards, tejicen

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-14 : 08:42:39
Refer
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=129314

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -