Following are the some of the new features of the Sql Server 2008 which are very helpful to the Sql Developers
1) Table-Valued Parameters in Sql Server: provides option for the Client Applications to pass multiple rows of Data to Sql Server.
Prior to this, if we were needed to pass multiple rows of Data from client application to Sql Server, then we use to model the input data as xml /comma separated values and pass it to the stored procedure and in Stored Procedure convert this xml/comma separated values to a table variable/temporary table.
You can find detailed information on the Table-Valued Parameters and also on calling Stored Procedure with Table-Valued Parameter from Sql Server and C# .Net Code @ http://sqlhints.com/2011/09/09/table-valued-parameters-in-sql-server/
2) Variable declaration allows initialization:
Prior to Sql Server 2008 to initialize a variable, we needed to first declare the variable and then we can initialize it by using SET/SELECT statement as shown below:
DECLARE @COUNT INT SET @COUNT =100
Now in Sql Server 2008 Variable declaration allows initialization similar to the one we do in C#. Now instead of writing two statements, we can write a single statement as below:
DECLARE @COUNT INT =100
3) Insert multiple rows using single INSERT Statement
To understand this feature first create an Employee Table by using the below script:
CREATE TABLE DBO.Employee ( Id INT, Name VARCHAR(50) )
Prior to Sql Server 2008, to insert multiple records we use to write statements like below:
INSERT INTO dbo.Employee VALUES(1,'Basavaraj') INSERT INTO dbo.Employee VALUES(2,'Shashank') INSERT INTO dbo.Employee VALUES(3,'Monty')
Now in Sql Server 2008 we can accomplish the same by writing script like below:
INSERT INTO dbo.Employee VALUES(1,'Basavaraj') ,(2,'Shashank') ,(3,'Monty')
4) Arithematic Assignment Operators
Now Sql Server 2008 also supports the Arithematic Assignment Operators like the below ones:
Operator Usage Description += SET @x+=@y Same as: SET @x = @x + @y -= SET @x-=@y Same as: SET @x = @x - @y *= SET @x*=@y Same as: SET @x = @x * @y /= SET @x/=@y Same as: SET @x = @x / @y %= SET @x%=@y Same as: SET @x = @x % @y
Example:
DEClARE @x INT =2 ,@y INT = 2 SET @x+=@y SELECT @x as x,@y as y Result: x y ----------- ----------- 4 2
5) MERGE Statement
Merge statement is one of the interesting T-Sql enhancements of Sql Server 2008. With Merge statement we can very efficiently perform multiple DML operations like INSERT, UPDATE and DELETE on the target table data based on Source table data and the join condition specified between them.
You can find detailed information on MERGE Statement @ http://sqlhints.com/2011/09/24/merge-statemen…ql-server-2008/
6) Sparse Column
Sparse Column is one more new feature introduced in SQL SERVER 2008. Storing a null value in a sparse column doesn’t take any space, but storing a non-null value in sparse column takes 4 bytes extra space than the non-sparse columns of the same data type.
You can find detailed information on Sparse Column @ http://sqlhints.com/2011/11/12/sparse-columns-in-sql-server-2008/
7) Date and Time Data Types
Date, Time, DateTime2 etc are the new date and time data type introduced in SQL SERVER 2008. You can find detailed information on DateTime2 datatype in the article Difference between DateTime and DateTime2 DataType.





