Tag Archives: DBA Scripts

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 restore database backup in SQL SERVER

In this article, I am going to explain the process of  Database restoration using the SQL Server Management Studio. In this article, I will try to explain this process in a simple way so that a database developer having little … Continue reading

Posted in SQL Advanced, SQL Database Restoration, SQL Server | Tagged , | 30 Comments

How to take Database backup in SQL SERVER

Introduction This article explain the simple way to take the database backup in SQL SERVER which can be easily understandable by the database programmer having little knowledge of DBA. For taking the database backup, we need to follow the given … Continue reading

Posted in SQL Database Backup, SQL Server | Tagged , | Leave a comment

Database Creation using SQL Sever Management Studio (SSMS)

In the previous article (Database Creation using Create Database command), I explained the database creation using the Create database command. In this article, I am going to explain the steps of creation a database using SQL Sever Management Studio (SSMS) … Continue reading

Posted in SQL Basic, SQL Server | Tagged , | 22 Comments

Database Creation using Create Database command

In SQL Server, database can be created by 2 ways:-  Using Create Database command  Using SQL Sever Management Studio (SSMS). In this article, I am going to explain the database creation using the command CREATE DATABASE. Syntax for creating a … Continue reading

Posted in SQL Basic, SQL Server | Tagged , | 31 Comments