Avatar of brettr
brettr

asked on 

Log location for timeouts, query errors

On SQL Server 2005, where can I find information on query errors (syntax errors, etc) and processes that could be blocking execution of other queries.  For example, a query that normally runs in 6 seconds very rarely and randomly might run in 45 seconds or north of one minute.  This is being executed directly on SQL Server Studio (query window).  Is info about what is causing that type of issue logged anywhere?
Microsoft SQL Server 2005

Avatar of undefined
Last Comment
brettr
ASKER CERTIFIED SOLUTION
Avatar of dishant57
dishant57

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of brettr
brettr

ASKER

Can these be targeted to one database or is it always server wide?
Avatar of dishant57
dishant57

There is a database id in some of the dmvs which you can use to filter, so to answer your question: Yes
Avatar of brettr
brettr

ASKER

Thanks.  Which sys database and table can I find the id to database name mapping?
Avatar of dishant57
dishant57

there is a database id column in sys.dm_exec_requests

And you can use db_name() function to get the name for a db id
Example: select db_name(8)
Avatar of brettr
brettr

ASKER

Is there anything that will output all DB IDs with names?
Avatar of dishant57
dishant57

Sure, why not. You have to design the query accordingly using that db_name() function.

So it will be something like this (you can design the queries the way you want):
select top 10 database_id, db_name(database_id) from sys.dm_exec_requests

( you can have more joins, cross apply outer apply based on what you are looking to retrieve)
Avatar of brettr
brettr

ASKER

Hmm, this will only get databases from the dm_exec_requests view.  I was referring to a simple list of DB_IDs/names on the server.  Sorry for the confusion.
Avatar of dishant57
dishant57

Two ways:

select * from sys.databases

select * from master.dbo.sysdatabases
Avatar of brettr
brettr

ASKER

Thanks.
Microsoft SQL Server 2005
Microsoft SQL Server 2005

Microsoft SQL Server 2005 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. It includes support for managing XML data and allows a database server to be exposed over web services using Tabular Data Stream (TDS) packets encapsulated within SOAP (protocol) requests.

72K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo