Monthly Archives: January 2015

RIGHT() function in SQL Server

SQL Server – RIGHT () function Right():- This function returns the specified number of characters from the Right part of the given character string. Syntax:- Select RIGHT ( character_expression , integer_expression ) For example, the below query will return two characters … Continue reading

Posted in SQL Basic, SQL Functions, SQL Server | Tagged | 30 Comments

LEFT() function in SQL Server

LEFT() function in SQL Server Left() Function  This function returns the specified number of characters from the left part of the given character string. Syntax Select LEFT ( character_expression , integer_expression )For example, the below query will return two characters … Continue reading

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

Between function in SQL Server

Between function in SQL Server This function is used to select the values within a specified range. These values can be of Int type or Date data type or Text data type. Syntax:- SELECT column_name(s) FROM table_name WHERE column_name BETWEEN … Continue reading

Posted in SQL Basic, SQL Functions, SQL Server | Tagged | Leave a comment

SQL Script to find the missing indexes

Script to find the missing indexes Performance tuning in SQL is important exercise and index creation is an important part of it. Sometimes base on the frequent SQL queries, we need to create some indexes or missing indexes which are enhance the … Continue reading

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

SQL SERVER – Data types

Data types in SQL Server In relational database, we store data in tabular form where data is divided into columns. Each column has a name and a data type which shows what type of data is going to store in … Continue reading

Posted in SQL Basic, SQL Data Types, SQL Server | Tagged | 32 Comments

SQL Server – Convert() function

Convert () function in SQL Server Convert () function is used to convert an expression from one data type to another data typeSyntax for CONVERT function CONVERT ( data_type [ ( length ) ] , expression [ , style ] ) Convert functions … Continue reading

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

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