I need to have an email sent (SS 2005x64), attaching a query to the email. The query is a stored proc, very similar to this thread's question.http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=6603&SearchTerms=Mail,query,paramhowever my parameter needs to be the result of getdate().. something like this -declare @f as varchar(1000)declare @t as datetimeset @t = getdate()set @f = 'exec vmfg.dbo.tsp_ProjectsShippedArchive ' + @tEXEC msdb.dbo.sp_send_dbmail @profile_name = 'SQL Administrator', @recipients = 'me@me.com', @subject = 'Projects to Archive', @body = 'hi', @query = @f, @attach_query_result_as_file = 1
The error I'm getting is : Conversion failed when converting datetime from character string. [SQLSTATE 22007] (Error 241) - I've tried a number of possible work arounds and calling getdate() in different places. Such asset @f = 'exec vmfg.dbo.tsp_ProjectsShippedArchive ' + getdate()
I know the db mail works as I use it for many other emails, any ideas? Thanks,