.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

Top 100 sql queries running on all database

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :Sql Server
hi This is sql server 2008, I am trying to find the top 100 queries on all database that has the high CPU usage. Trying to find the database, CPU usage and queries. I have something here, but does not show the query part. SELECT   [sql_handle]   ,[statement_start_offset]   ,[statement_end_offset]   ,[plan_generation_num]   ,[plan_handle]   ,[creation_time]   ,[last_execution_time]   ,[execution_count]   ,[snapshot_execution_count]   ,[total_worker_time]   ,[snapshot_worker_time]   ,[min_worker_time]   ,[max_worker_time]   ,[total_physical_reads]   ,[snapshot_physical_reads]   ,[min_physical_reads]   ,[max_physical_reads]   ,[total_logical_writes]   ,[snapshot_logical_writes]   ,[min_logical_writes]   ,[max_logical_writes]   ,[total_logical_reads]   ,[snapshot_logical_reads]   ,[min_logical_reads]   ,[max_logical_reads]   ,[total_clr_time]   ,[snapshot_clr_time]   ,[min_clr_time]   ,[max_clr_time]   ,[total_elapsed_time]   ,[snapshot_elapsed_time]   ,[min_elapsed_time]   ,[max_elapsed_time]   ,[collection_time]   ,[snapshot_id]   FROM [Data Collection].[snapshots].[query_stats]    

View Complete Post

More Related Resource Links

Parallel LINQ: Running Queries On Multi-Core Processors


Use Parallel Language Integrated Query (PLINQ) to take advantage of multi-processor computers and the newer wave of multi-core processors.

Joe Duffy and Ed Essey

MSDN Magazine October 2007

How to stop the repeated database queries for roles


Hello, friends,

We have a web application using VS 2008, c#. We try to filter siteMap nodes based on security roles. We have our customized the mether GetRolesForUser() in RoleProvider class to determine a user's role. In this method, roles will be returned by querying an SQL Server database.

However, we found that each time a page was loaded/refershed, this  GetRolesForUser() was called, and the database would be queried. This is too MUCH and expensive.

We thought the roles should be queried only once when a user logs in. After that, role info should be stored somewhere for this user, rather than query DB all the time.

Any ideas, reference paper, snipet,...,?

Thanks a lot!

Error when running an SQL script to restore a database on SQL Server 2008 R2 Express

Hi, At work, I use SQL Server 2008 Express running on Windows XP Professional Service Pack 3. At home, I also use SQL Server 2008 Express running on Windows XP Professional Service Pack 3. Whenever I do work on the database at work, I usually restore the database at home (or vice versa) I have been using the following SQL scripts to back up the database and to restore the same database (at work or at home). BackupRealEstate.sql USE Master BACKUP DATABASE [RealEstate] TO DISK = N'F:\My Documents\My Database\RealEstate.bak' WITH NOFORMAT, INIT, NAME = N'RealEstate-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10 GO RestoreRealEstate.sql USE Master RESTORE DATABASE [RealEstate] FROM DISK = N'F:\My Documents\My Database\RealEstate.bak' WITH  FILE = 1, NOUNLOAD, REPLACE, STATS = 10 GO Everything worked fine until I replaced my 8yo home computer with a newer and faster one. My new home computer is running Windows 7 Home Premium and I use the latest SQL Server 2008 R2 Express. When I tried to run the above restore SQL script, I got the following error message: Msg 3101, Level 16, State 1, Line 2 Exclusive access could not be obtained because the database is in use. Msg 3013, Level 16, State 1, Line 2 RESTORE DATABASE is terminating abnormally. There was no other application/process using this database. Can someone please help me? Regards,

Query to list currently running queries on the sql server 2000

Hi all Who to check, what all queries are running curently on the sql server 2000, I need to list who all logged in and what queries are getting executed and how long its running. Thanks in advance. shan  

Running an XMLA script of a database on another database



I used the "Script Database as -> Create to" option on an Analysis Services DB and now I'm trying to run the script on another DB server, but I get an error message that it already exists, and indeed it does, but then when I delete it and run the script again, I get a message that it doesn't exist(!) or the user doesn't have access to it (but it's actually defined as having server-wide permissions). Does anyone have an idea what the problem might be? What am I missing here?


Parameter queries running multiple times


Currently running SQL 2005 sp2 SSRS.  We were in the process of tuning a report's queries against DB2 when our DBA noticed in the tracing log that the queries used for the parameter list is ran 2 times for each parameter.  They are cascading parameters with a Date only, but we tested removing the dependancy and the parameter query still ran 2 times.  We tested setting all the default values for initially opening the report and after we just opened the report and it rendered, nothing else was touched, the parameter queries all ran 2 times.  Any idea of why this happens.  I tried to search for this and couldn't find anything.


Processes running lond queries are killed by SQL Server 2008



We recently upgraded a server from 2005 to 2008. We have some long running SP's (1 or 2 min) that used to run ok on 2005. Since the upgrade, whenever we run those SP's after some time, the process ID is no longer up on the server and the SSMS on the client indicates that the query is still running. Is there a new timeout parameter or something like that on 2008 that drops the long running procedures?


"Create failed for Database" when running under administrator account without built-in account.


- I am having an application which can install several instances of sql 2008 express on my pc, in built-in administrator windows account, everthing worked well, then i created more an account and grant administrator permission on this account,  but when i logged into this account, after logged on SQL management by Windows authtication mode, then attempt to create any database in SQL management studio, i got an exception as below:

TITLE: Microsoft SQL Server Management Studio

Create failed for Database 'test'.  (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1447.4+((KJ_RTM).100213-0103+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Database&LinkId=20476


An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)


Simple Database connection check to seee if the database server is up and running using linq


I am using Linq

Before i start executing my query, want to check if the database connection is being established, i.e if the database server is up and running.

Incase database is down, display appropriate error message?

How can i do that?


Multiple database support with Entity Framework

One of the features introduced in Entity Framework is being database independent. Which mean each database provider can support Entity Framework by implementing its provider.

This feature allows you build applications independent from the underplaying database provider. In this post I'm going to show how to build an application that support multiple databases using same conceptual model made by Entity Framework.

Export Visio Database Table Names to Excel

If you use the Enterprise Architect edition of Microsoft Visio for data modeling regularly, then there is a good chance that at some point you've wanted to export just the table names into Excel. You might want to do this to map logical ERD entities to physical data model tables, track project status by entity, or track overlap between database versions.

MS SQL Server: Disconnect Users From Database - Kill User Session

If you ever wanted to restore your database from a SQL backup file (.bak), but there are still users connected to your database, the backup operation will fail causing the error: Exclusive access could not be obtained because the database is in use.

Publishing SQL Server Database using Publishing Wizard : Tips & Tricks

We can use SQL Server Publishing Wizard to deploy our local Database to remote hosting server/production server.This feature is available in SQL Server 2008/VWD 2008.

Below is the complete step by step guide of this process.

Adding Rows in GridView without using a Database

This article describes on how to add rows in GridView without using a database. Basically the GridView will be populated with data based on the values entered in the TextBox on Button Click and retain the GridView data on post back.

Adding Multiple Columns and Rows in GridView without using a Database

This article describes on how to add multiple columns and rows in GridView without using a database. Basically the GridView will be populated with data based on the values entered in each TextBoxes on Button Click and retain the GridView data on post back.

ASP.NET Database Tutorial

This tutorial will show you how to display data using the .NET GridView Control, ASP.NET 2.0 and VB.NET

The GridView control is a powerful tool and is simple to implement.

First, you will need to import the System.Data.SqlClient namespace.

Connestion string create any database server

This links important to how to create connection string to any data base sever.
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