Category Archives: SQL Basic Concepts

SQL Basic Concepts

IN clause in SQL Server

With IN clause, we can specify multiple values in a WHERE clause. For example, in case of “IN”, one can use the subquery to get the multiple values in the IN clause or we can have predefined values. In this … Continue reading

Posted in SQL Basic Concepts, SQL Server | Tagged , | 32 Comments

AND and OR Operator in Sql Server

And & Or:- These Operators are used to further filter the recordset return by SQL queries when more than one conditions are specified. In case of “AND” all the conditions must be true and in case of “OR” any of … Continue reading

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

Except command in SQL Server

Except command in SQL Server returns the distinct values from the left query that are not also found on the right query. For Except command, below basic rules must be followed. The number and the order of the columns must … Continue reading

Posted in SQL Basic Concepts, SQL Server | Tagged | 19 Comments

Intersection command in SQL Server

This function is used to returns distinct values that are returned by both the query on the left and right sides of the INTERSECT operand. For intersection command, below basic rules must be followed. The number and the order of … Continue reading

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

While loop in SQL server

While loop in SQL server Introduction In While loop, we set a condition for the repeated execution of a Code block. So we use while loop in SQL Server to┬árepeat execution of a SQL Code block or a SQL Statement … Continue reading

Posted in SQL Basic Concepts, SQL Server, SQL While loop | Tagged , , , | 13 Comments

Stuff VS Replace function in SQL Server

Stuff VS Replace function Stuff Function This function is used to replace string from the given start position, passed as 2nd argument with string passed as last argument. In Stuff function, 3rd argument defines the number of characters which are … Continue reading

Posted in SQL Basic Concepts, SQL Server | Tagged | 6 Comments

Case Statement/ Expression in SQL Server

Case Statement/ Expression in SQL server  Sometimes we need to get one result output from multiple possible outcomes based on the evaluation of some expression. This expression can be a simple case expression which compares an expression with a set … Continue reading

Posted in Most Imp SQL Concepts, SQL Basic Concepts, SQL Server | Tagged , | 1 Comment

Adding , Deleting and Updating a Column in a table

Many times we need to alter the table definition by adding , deleting or updating a column in the table. In this article, I am trying to explain the following :- 1. How to add a column 2. How to … Continue reading

Posted in SQL Basic Concepts, SQL Server | Tagged , | 29 Comments

SQL Server-Table Variable

Table variable:- SQL Server provides an variable known as table variable which is used to store data in a similar way as we store data in physical tables but with some limitations. Like other SQL variable, it is also declare with the help … Continue reading

Posted in SQL Basic Concepts, SQL Server, SQL Temporary Tables | Tagged , | 4 Comments

How to change the database collation

To change the collation of an database following commands can be used: ALTER DATABASE [database name] SET SINGLE_USER WITH ROLLBACK IMMEDIATE ALTER DATABASE  [database name]  COLLATE Newcollation ALTER DATABASE  [database name]  SET MULTI_USER For example , suppose if the name of your database is learningdb and you want to change the collation to the collation SQL_Latin1_General_CP1257_CI_AS, … Continue reading

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