SQL Server 2008 - New Features


I came across few new features in 2008 and I thought of sharing with you all. Two of them are, 1. Row Constructor : adds ability to insert multiple values using a single insert statement. 2. Grouping set: using this feature, you can group the records based on more than one column in a single query. Find SQL Server 2008 - New Features

Learn about SQL Server 2008 - New Features


I would like to highlight two of the new features available in SQL Server 2008.

1. Row Constructor:


With earlier version of SQL Server to insert mutiple rows into a table with different values for column, we used to write multiple insert statements. If we need 100 rows then we have to write 100 insert statements.

With SQL Server 2008 we can do the same with a single insert statement like the following,


INSERT INTO [table_name] ([column1], [column2], etc)

VALUES('column1_value','column2_value', etc,),--Row1

('column1_value','column2_value', etc,) --Row2


2. Grouping Sets:


With previous versions, if we want to get counts on records based on each column we had to write separate queries to get them.

Ex:


To get count of name and age from table person. We would write the following two queries.


SELECT name, count(*) from person

GROUP BY name

SELECT age, count(*) from person

GROUP BY age


But with SQL Server 2008 it can be done with the Grouping sets.


SELECT name, age, count(*) from person

GROUP BY GROUPING SETS(

(name), (age)

)

ORDER BY name, age


Comments

Author: prasad18 Aug 2011 Member Level: Gold   Points : 0

Hi Natesan

Thanks for your post....this Article is nice

Author: Raja25 Aug 2011 Member Level: Silver   Points : 0

Hi,

Thanks for u r updates..

Thanks,
Raja

Author: anita singh30 Aug 2011 Member Level: Gold   Points : 1

one more feature that is excellent one is given in this link

http:
//www.getproductprice.
com/Ads-where-to-use-merge-statement-with-example.aspx



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: