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,) --Row22. 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
Hi Natesan
Thanks for your post....this Article is nice