June 26, 2009 at 12:37 pm
This might be simple, but i can't seem to get it right. I imagine its with the quotes... the @subject isn't working....
help!
SET NOCOUNT ON
DECLARE @database_profile_name varchar(35)
, @dbname varchar (35)
set @dbname = 'TESTDB'
exec msdb.dbo.usp_GetMailProfile @database_profile_name output
EXEC msdb.dbo.sp_send_dbmail
@profile_name = @database_profile_name
, @recipients = 'me@me.com'
, @subject = 'SUCCESS : Restore '' + @DBNAME + ''completed'
, @query = 'SET NOCOUNT ON
select top 1 restore_date as LAST_RESTORE from msdb.dbo.restorehistory
where destination_database_name = ''' + @DBNAME + '''
order by restore_date desc'
the error is saying syntax with the '+' is wrong
June 26, 2009 at 12:53 pm
ahhh... i think i got it... can't concatenate inside the variable of a SP, or function.... i guess i'll just wait for any confirmations....
have to set a new variable with the @cmd and then call the variable in the @subject = @cmd...
June 26, 2009 at 9:09 pm
knight (6/26/2009)
ahhh... i think i got it... can't concatenate inside the variable of a SP, or function.... i guess i'll just wait for any confirmations....have to set a new variable with the @cmd and then call the variable in the @subject = @cmd...
Correct. You need to complete the concatenation outside the call to dbmail.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply