.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

SQL Server 2005/2008 Query Monitoring via DMVs

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :

My understanding is that sys.dm_exec_query_stats is for archive aggreated query statistics so I’ve been using the query below to monitor active long running queries and it works fine for single statements – however it seems to return hugely inflated total_elapsed_time values with some procs or functions where multiple statements are run. I’m also interested if anyone know how to find query completion times from DMVs?


Select …<some columns>
FROM sys.dm_exec_requests er
CROSS APPLY sys.dm_exec_sql_text(er.sql_handle) as st
INNER JOIN sys.dm_exec_sessions AS es
ON es.session_id = er.session_id
INNER JOIN sys.dm_exec_connections AS ec
ON ec.session_id = es.session_id
where er.total_elapsed_time / 1000.0 > @ElapsedThreshold
ORDER BY er.total_elapsed_time DESC;

View Complete Post

More Related Resource Links

SQL server 2005 2008


i cant install sql server 2005 nor 2008 on my windows 7 os

i read about somthing like adding new account when installing sql 2008 to provision the server or so, but didnt know how,,,

can you plz help me??


Query on XML datatype in SQL Server 2008

Hi All, In table I have column with XML datatype. I can able to read the below XML tag. SET   @Title = CAST(@XMLContent.query('data(root/chemicalName)') AS VARCHAR(50)) <root><chemicalName>Sulphuric acid</chemicalName></root> but how can I read (in SQL Server 2008) with multiple rows in it, and how to know the list of child nodes and data of it dynamically? <Root> <Row> < CurrencyCode>GBP</CurrencyCode> < CurrencyName>POUND (STERLING)</CurrencyName> </ Row> <Row> < CurrencyCode>INR</CurrencyCode> < CurrencyName>Rupee</CurrencyName> </ Row></

Replication between SQL Server 2005 and SQL Server 2008

Hi,    We were using SQL Server Transactional Replication between two SQL Server 2005 servers. Now we are going to upgrade the Publisher server to SQL Server 2008, Distributor Server remains as SQL Server 2005.     Can anyone let me know what is the challenges we need to face when configuring Replication between SQL Server 2005 and SQL Server 2008. Replication Method - Transactional Replication Distributor/Subscriber - SQL Server 2005 Publisher     -  SQL Server 208 Regards, Fazlu.

SQL Server 2005 as Distributor, Subscriber - SQL Server 2008 as Publisher

Hi,           I am creating a Distributor on SQL Server 2005 the server name is Server1 and Server1 is the Subscriber as well, we are using Push Subscription           Publisher is on SQL Server 2008, Server2. When i try to create a Publications, it throws the following error.          Server "Server1" is an Older Version of SQL Server and cannot be the Distributor for Server  'Server2'  Server1 - Distributor, Subscriber  Server2 - Publisher Is there any way to overcome this issue..? Regards, Fazlu.

Moving a Copy of SQL Report Server 2005 and Upgrade to 2008

Hello, We have SQL 2005 Report Server in a Windows 2003 64 bit server box. We want to create a copy of this report server database somewhere in the domain, so that we can access it for a different purpose. My question is, will there be any complications with this? I'm thinking about the encryption key that's needed to access the database. If we are successful with this, we might also want to upgrade to SQL 2008. Thanks for your help,   Elizabeth K.

Can SSAS 2005 run with Sql Server 2008 database engine?

Are there any known issues of running SSAS 2005 with SQL Server 2008 database engine?

Best practice for user defined error messages in SQL Server 2005/2008 --Need help

My requirement is to setup a standard practice for our team in handling DB erros and also  user defined messages. We are handling exceptions using Raiseerror method with in Try and Catch blocks.  For user defined message, we are using Sp_addmessage to add our application specific error/warning messages with error codess>80000.  Ex: 80001 | Company name already exists. please check. Here is the sample code ********************************************************************* CREATE PROCEDURE [dbo].[usp_CompanyProfile_insert]  -- Add the parameters for the stored procedure here  (@company_name VARCHAR(50),  @company_code VARCHAR(3),  @user_id INT  ) AS BEGIN  -- SET NOCOUNT ON added to prevent extra result sets from  -- interfering with SELECT statements.  SET NOCOUNT ON;  BEGIN TRY -- Begin Try Block      -- Validate company name   IF EXISTS (SELECT company_id FROM companyprofile WHERE company_name = @company_name)    RAISERROR(90021, 16, 1)      INSERT INTO companyprofile (company_name,       company_code,       createdby)   VALUES(@company_name,     @company_code,     @user_id)    END TRY  -- End Try Block &

Sql Server 2005 ( remove header information from query output file "Job 'bustd_Daily_Query_Output_1

Dear All,I have scheduled job for querying output & asve it into particuler folder....but in the top of file i getting the message like "Job 'bustd_Daily_Query_Output_13July09' : Step 1, 'Query1' : Began Executing 2009-07-13 16:32:06"I want to remove this & want output in txt file format without above header....RegardsRavendra Cindia

SQL server 2008 - Unable to tune a query with DTA

We are on:Verison: SQL 2008 [10.0.2531] on windows server 2008. Both are enterprise editions.When I highlight the query and right-click, then select Analyze Query in Database Engine Tuning Advisor, then click "Start Analysis",  I get the following error in the "Message" column of "Progress" tab of DTA: Cannot initialize tuning. [.Net SqlClient Data Provider] If I click on this, it displays this message: "Cannot find either column 'msdb' or the user-defined function or aggregate 'msdb.dbo.fn_DTA_unquote_dbname', or the name is ambiguous. Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count=0, current count=1. (Microsoft SQL Server Error: 4121)Please let me know if you guys have any ideas on this error. Thanks,Sam. 

Management Studio sql 2005 Express on Windows Server 2008 r2

Hi , i have install a application that use sql server express 2005 on a server with OS windows server 2008 r2. My question is how to make automatic backup of my database , because i cant install SQL Server 2005 Management Console on my server .   Please help me Thanks

SQL server management studio 2008 freezes when running a query to Grid result

Hello, I've got problems when I run a Query to a grid result using SQL server management studio 2008 under W7 pro. When I execute the query, the first part of the grid returns, but then it freezes. The query should present a double resultset and contains approx 6100 records, devided over 2 grids. Strange enough, the query runs fine when I export to TXT or to a file. It seems though that the problem is building the grid. When it occurs I cannot end the application bij shutting down de SSMS window, but have to kill the Ssms.exe. In task manager I see only 25% CPU usage and approx 20% memory usage. Nothing exiting there I guess. Suggestions anybody? Microsoft SQL Server Management Studio      10.0.2531.0 Microsoft Analysis Services Client Tools      10.0.3798.0 Microsoft Data Access Components (MDAC)      6.1.7600.16385 Microsoft MSXML      3.0 4.0 5.0 6.0 Microsoft Internet Explorer      8.0.7600.16385 Microsoft .NET Framework      2.0.50727.4952 Operating System      6.0.6001 regards, Pim

from SQL Server 2005 to SQL Server express 2008

I am trying to transfer some tables and stored procedures from SQL Server 2005 to Express 2008. Any ideas. I have tried using Management studio, but it isn't working....Thanks

Using SQL Server Replication for SQL Server 2005 and 2008

I have an ASP.NET application that uses replication, and uses the RMO DLLs to do this. I initially built the application against the 2005 version of the DLLs and have it running successfully against SQL Server 2005. However, when I try running it against SQL Server 2008 it doesn't work. Initially I didn't deploy the Microsoft.SqlServer.* DLLs with my app - instead relying on them being in place on the server on which it was installed. However, when trying to make it work against SQL Server 2008 it was looking for the 2005 version DLLs which it wasn't able to locate. Following some other advice I read online I have now swapped out the 2005 DLLs and referenced the 2008 assemblies in my .NET project. In my MSI I now also deploy (i.e. redistribute) the SQL Server 2008 DLLs to the bin folder of my ASP.NET project. Now, when I try to run the application against SQL Server 2005 it fails to load the Microsoft.SqlServer.Replication assembly. I run depends.exe against this and find that it's dependent on SQLNCLI10.DLL which is missing on my machine with only SQL Server 2005 on it. So, what am I to do? Is this possible? How do I get around this?

Can I have two instances (SQL 2005 - 2008) at the same server?

Hello, I have a Windows 2008 R2 with sql server 2005 x64. I would like to have both instances (SQL server 2005 x64 and 2008 x64) at the same server, each one having its own databases. Is the possible? What should I pay attention to? Thank youChristos

How to start SQL Server 2005 (Visual Studio 2008)

I am just starting to work with Visual Studio 2008 (VB) to creat WPF apps and am trying to work with sql server. I want to create databases on my computer to be used with single client applications. When I try to see if the server is running it doesn't appear to be. Is there some special process that I need to do to start the server so I can create some sample databases to work with in Visual Studio? Working with Windows XP, Visual Studio 2008, SQL Server 2005.

Run Reporting services 2005 with databases housed on SQL Server 2008?

Hi, I have a RS 2005 install in which the ReportServer and ReportServerTempDB databases reside on a different SQL Server 2005 server. I am planning to upgrade both to 2008 at some point but would like to do the SQL database engine first. So I would be running something like this: Server A: SQL 2005 Reporting Services Server B: SQL 2008 database engine - housing ReportServer and ReportServerTempDB Is this configuration supported? If I do this would I just need to run the DB's in 9.0 compatibility mode until we upgrade the RS server? Would it be better to upgrade the RS box first or both of them at the same time instead of doing the database engine first?

How to query the Active directory using SQL Server 2005

Hi, I am trying to query Active server from Sql Server 2005 and getting error I used following script to create link server EXEC sp_addlinkedserver 'ADSI3', 'Active Directory Services 111', 'ADSDSOObject', 'adsdatasource' and then trying to connect using following statement SELECT   * FROM OpenQuery(ADSI, 'SELECT * FROM ''LDAP://DC=local.mycompany.ca'' WHERE objectCategory=''User'' ') and getting following error An error occurred while preparing the query "SELECT * FROM 'LDAP://DC=local.resound.ca' WHERE objectCategory='User' " for execution against OLE DB provider "ADSDSOObject" for linked server "ADSI". Please let me know if you know How to query the Active directory using SQL Server 2005 Thanks, Raj    Dreaming a world without any war in anywhere
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend