I am working on a SQL stored procedure (below). So far the below script runs successfully if I don't put variables in the body. When I do, it returns "Conversion failed when converting the varchar value ' Unix Timestamp' to data type int." Any thoughts on how I might be able to accomplish this?
SQL
SETNOCOUNTONDECLARE@UnixTimeint;DECLARE@countinfoint,@bodyTextnvarchar(max)SET@bodyText=N''+@UnixTime+' Unix Timestamp'EXECmsdb.dbo.sp_send_dbmail@profile_name='EmailProfile',@recipients='user1@gmail.com',@query='SET @UnixTime = (DATEDIFF(s,''1970-01-01 00:00:00'',GETUTCDATE())-31701600) SET @countinfo = (SELECT COUNT (*) FROM [DatabaseName].[dbo].[TableName] WHERE Date_Time < @UnixTime)',@subject='SQL Maintenance Trim - Start',@body=@bodyText,@body_format='HTML'