Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find what caused errors reported in a SQL Server profiler trace?

I was running a trace on a Sql Server 2005 using the profiler and need to find out what is causing the reported errors.

I used the "blank" template, and selected all columns of the following events:

  • Exception
  • Exchange Spill Event
  • Execution Warnings
  • Hash Warnings
  • Missing Column Statistics
  • Missing Join Predicate

I noticed a number of these errors in the "TextData" column:

  • Error: 156, Severity: 16, State: 0
  • Error: 208, Severity: 16, State: 0

I looked up the errors (Incorrect syntax, Invalid object name), but how can I tell what stored procedure or query is causing them?

like image 734
KM. Avatar asked May 01 '09 18:05

KM.


People also ask

What kind of information can you get from SQL trace?

The SQL Trace facility provides performance information on individual SQL statements.

How do I trace a traffic hit in SQL Server?

How do you trace the traffic hitting a SQL Server? Example: "You use SQL profiler to trace the traffic on the SQL Server instance. To narrow down the transactions that are captured, you can use a filter. The trace files can be searched, saved or even replayed to help with troubleshooting."

What tool lets you analyze a server trace from SQL Server profiler?

Database Engine Tuning Advisor After quickly describing SQL Server Profiler, it is worth mentioning that there is another tool provided by SQL Server that can read and analyze the traces created by the Profiler. This tool is called SQL Server Tuning Advisor. You can access it from SQL Server Management Studio.

Where is the SQL Server error log?

By default, the error log is located at Program Files\Microsoft SQL Server\MSSQL. n \MSSQL\LOG\ERRORLOG and ERRORLOG.


1 Answers

Don't worry about the 208 errors. 208 is "Object not found". Profiler picks up these due to what's called 'deferred name resolution'.

Take the following procedure.

CREATE PROCEDURE Demo AS
  CREATE TABLE #Temp (ID int)
  INSERT INTO #Temp VALUES (1)
  SELECT ID FROM #Temp
GO

That proc will run fine without any errors however, if you have a profiler trace running, you'll see one or two instances of error 208. It's because the table #Temp doesn't exist when the proc starts, which is when the code is parsed and bound. The process of binding to the underlying objects fails.

Once the create table runs, the other statements get recompiled and bound to the correct table and run without error.

The only place you'll see that deferred resolution error is in profiler.

like image 50
GilaMonster Avatar answered Oct 09 '22 11:10

GilaMonster