Category Archives: SQL Server

This category contains all SQL related articles

SQL Script to find the list of all the jobs failed yesterday

One of the important task of any DBA is to find out all the jobs which are failed yesterday. Below SQL Script can be used to find out all the jobs which are failed yesterday. SELECT DISTINCT CAST(CONVERT(datetime,CAST(run_date AS char(8)),101) … Continue reading

Posted in DBA, SQL Advanced, SQL Server | Tagged , | Leave a comment

SQL Script to search stored procedures containing a given text

Sometimes we need to find out how many stored procedures contains a given text. Below SQL query can be used to find out the list of all the stored procedures which contains a  particular given text as input. SELECT OBJECT_NAME(object_id), … Continue reading

Posted in DBA, SQL Advanced, SQL Server | Tagged , | 32 Comments

SQL Script to find the tables created from a given date

Below is the SQL query which can be used to find out the tables which are created or modified on or from a given date. SELECT         [name] as Tablename        ,create_date       … Continue reading

Posted in DBA, SQL Advanced, SQL Server | Tagged , | 29 Comments

SQL Script to find the databases size

Sometimes we need to find out the size of the database on a server. Below SQL Scripts can be used to find out the size of all the databases created on the server.  ;WITH DBSize (SqlServerInstanceName, DatabaseName, DatabaseSize, DBLogSize, TotalDBSize) … Continue reading

Posted in DBA, SQL Advanced, SQL Server | Tagged , | Leave a comment

T-SQL script to find the growth size of database files

Below query can be used to see the growth size of database files. DECLARE @filename NVARCHAR(1000); DECLARE @bc INT; DECLARE @ec INT; DECLARE @bfn VARCHAR(1000); DECLARE @efn VARCHAR(10); — Get the name of the current default trace SELECT @filename = … Continue reading

Posted in DBA, SQL Advanced, SQL Server | Tagged , | 32 Comments

T-SQL script to find the highly populated tables in database

Sometimes we need to check which tables of our database is highly populated. Below is the T-SQL Script which we can use to find out that. SELECT      t.NAME AS TableName,     i.name as indexName,     sum(p.rows) … Continue reading

Posted in DBA, SQL Advanced, SQL Server | Tagged , | 27 Comments

SQL Script to find the last executed commands on the SQl Server

Sometimes we needs to find out the last executed commands on the database server.  Below is the SQL script share by one of my friend Ken Watson to find out the last executed queries. SELECT usecounts, cacheobjtype, objtype, text  FROM … Continue reading

Posted in DBA, SQL Advanced, SQL Server | Tagged | 30 Comments

Script to find the Fragmentation of indexes

Script to find the Fragmentation in Indexes In my previous articles, Fragmentation in SQL Server and Rebuild And Reorganization of Indexes , we talk in detail about Index fragmentation and rebuild or reorganize the indexes. Below is the SQL script which we … Continue reading

Posted in DBA, SQL Advanced, SQL Indexes, SQL Server | Tagged , | 33 Comments

Script to find all the running queries/jobs on the Database Server

Below is the query to find out all the Queries and their details like SSID etc. running on the SQL Server from all databases. It helps in finding out which queries/jobs running on the server. It can be helpful in … Continue reading

Posted in DBA, SQL Advanced, SQL Server | Tagged , | 3 Comments

How to pass Microsoft Certification Exams

Many times I was asked how to pass Microsoft certifications and how difficult it is. In my point of view, it simple to crack Microsoft certification exams if you have worked hard on basic concepts and implemented most of the … Continue reading

Posted in Miscellaneous, SQL Advanced, SQL Server | Tagged , | 15 Comments