Category Archives: SQL Basic Concepts

SQL Basic Concepts

Stuff VS Replace function in SQL Server

By | November 25, 2013

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 going to be replaced.   Syntax:- STUFF ( character_expression , start , length , replaceWith_expression ) For example:-… Read More »

Case Statement/ Expression in SQL Server

By | November 25, 2013

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 of Expression/Values to determine the result or it can be a search case expression… Read More »

SQL Server-Table Variable

By | January 10, 2012

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 of the Declare keyword with @ prefix. The Syntax of declaring a table variable is… Read More »

How to rename a Table in Sql Server

By | January 2, 2012

To rename a column in a SQL Table following command can be reused: SP_RENAME  ‘old table name’, ‘New table name’ For example, if we want to rename the table from employee to employeemaster, following command can be used. SP_RENAME  ’employee’, ’employeemaster’ This command will rename the table from employee to employeemaster. Database Consultant with more than 11.5… Read More »

How to change the database collation

By | January 2, 2012

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, then following commands can be used:- ALTER DATABASE  learningdb  SET SINGLE_USER WITH ROLLBACKIMMEDIATE ALTER DATABASE  learningdb  COLLATE SQL_Latin1_General_CP1257_CI_AS ALTER DATABASE  learningdb  SET MULTI_USER Database Consultant with more than… Read More »