|
|
|
SSChampion
        
Group: General Forum Members
Last Login: 2 days ago @ 12:22 PM
Points: 10,571,
Visits: 11,871
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, December 26, 2012 7:59 AM
Points: 7,
Visits: 25
|
|
Thanks for the article.After reboot, I tried going through the steps but when I set up the alert at the end, I get the following error message: The specified object_name('SQLServer:Loks') does not exist. (Microsoft SQL Server, Error: 14262)
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, September 24, 2012 11:35 PM
Points: 2,
Visits: 7
|
|
Hey Geoff. Thanks for pointing that out. I just followed up the limitations due to the query happening on a different session. Have you tried it with Global Temporary tables using the double hash syntax? ##tablename?
regards,
Alex
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Thursday, May 16, 2013 1:46 PM
Points: 18,732,
Visits: 12,329
|
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 6:49 PM
Points: 366,
Visits: 689
|
|
When I run the sql contained in the job within the QA it works Ok and I get a mail. However when I try and execute the job itself I get the following error:
Error formatting query, probably invalid parameters [SQLSTATE 42000] (Error 22050). The step failed.
SQL with email just masked:
CREATE TABLE tempdb.dbo.ErrorLog (Id int IDENTITY (1, 1) NOT NULL, logdate DATETIME, procInfo VARCHAR(10), ERRORLOG VARCHAR(MAX)) --== We create a 3 column table to hold the contents of the SQL Server Error log. ==-- --== Then we insert the actual data from the Error log into our newly created table. ==-- INSERT INTO tempdb.dbo.ErrorLog EXEC master.dbo.sp_readerrorlog --== With our table created and populated, we can now use the info inside of it. ==-- BEGIN --== Set a variable to get our instance name. ==-- --== We do this so the email we receive makes more sense. ==-- declare @servername nvarchar(150) set @servername = @@servername --== We set another variable to create a subject line for the email. ==-- declare @mysubject nvarchar(200) set @mysubject = 'Deadlock event notification on server '+@servername+'.' --== Now we will prepare and send the email. Change the email address to suite your environment. ==-- EXEC msdb.dbo.sp_send_dbmail @profile_name = 'default', @recipients='xxxxxxxxxxxxxxxxxx', @subject = @mysubject, @body = 'Deadlock has occurred. View attachment to see the deadlock info', @query = 'select logdate, procInfo, ERRORLOG from tempdb.dbo.ErrorLog where Id >= (select TOP 1 Id from tempdb.dbo.ErrorLog WHERE ERRORLOG Like ''%Deadlock encountered%'' order by Id DESC)', @query_result_width = 600, @attach_query_result_as_file = 1 END
--== Clean up our process by dropping our temporary table. ==-- DROP TABLE tempdb.dbo.ErrorLog
Any ideas? I'm running 2008 R2 but not sure if that should make a difference.Thanks!
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, September 08, 2011 2:33 PM
Points: 2,
Visits: 9
|
|
| I'm trying to remember. Do you have to turn back on DBCC TRACEON each time you restart the instance?
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 11:01 AM
Points: 485,
Visits: 1,566
|
|
chuckh 3191 (12/14/2010) I'm trying to remember. Do you have to turn back on DBCC TRACEON each time you restart the instance?
yes.
from the article -
It is important to note that setting trace flags this way will only work until the next time SQL Server is restarted. If you want to make sure your trace flags are always set this way, you can edit the startup options of SQL Server by using the -T switch or creating a SQL Agent job to run that code when the Agent starts.
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, March 19, 2013 9:21 AM
Points: 36,
Visits: 727
|
|
Great post,
But i have a problem that i am receving the emails with empty Attachment and also what is the Schedule for Sql Agent Job? l
ogdate procInfo ERRORLOG ----------------------- ---------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
(0 rows affected)
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Thursday, March 28, 2013 11:51 AM
Points: 50,
Visits: 62
|
|
Doesn't enabling deadlock graph take performance hit on the system.....true or not? As on our systems i have seen some performance hit when deadlock graph is enabled.
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 11:01 AM
Points: 485,
Visits: 1,566
|
|
| yes, there is a very minor hit, but consider the alternative. everything comes at a cost. would you rather have unknown deadlocks or (IMHO) a barely measurable hit in performance?
|
|
|
|