Category Archives: SQL Basic

Script to find complete months between two given dates

Complete months between two given dates Below script will help in finding the complete months within the 2 given dates. In the below script we takes below dates as exampleStartdate =2015-07-05 Enddate =2016-01-06 /**********************Script Start**************************/ IF (object_id(‘tempdb..#month’) is not null) … Continue reading

Posted in Interview Questions, SQL Basic, SQL Server | Tagged , , | Leave a comment

Script to find the complete weeks within two given dates

Complete weeks within two given dates Sometimes we need to find out the complete weeks within two given dates. Below script will help in finding the complete weeks within 2 given dates. In this script, I have used below dates … Continue reading

Posted in Interview Questions, SQL Basic, SQL Server, SQL Tips | Tagged , | 21 Comments

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 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

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

Group by…..Having Clause

Group By:- Group By clauses is used to groups rows based on the distinct values of the specified columns. The syntax of the Group by clause is:-   Select column1, column2, column3, aggregate_function(expression )            From … Continue reading

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