Row Constructor in SQL-2008

 

One of the cool features of SQL 2008 is Row Constructor. The concept ‘Row Constructors in SQL Server 2008’ basically deals with the crux of multiple inserts performed at one shot. Instead of having to call multiple inserts, we could just insert multiple rows with a single TSQL Statement.

    The following example inserts 3 rows into User Table in a single call. Pay attention to 'VALUES' in the following statement. You just need to specify one INSERT keyword and start filling values separated by comma.

INSERT INTO Product([Name],[ProductSKU],[CreatedDt])
VALUES
('Test Product1', 'CW76548S', '5/12/2008'),
('Test Product2', 'CW98JK76', 6/12/2008'),
('Test Product3', 'CW909876', '7/12/2008')

 

You can also use Row Constructors as a DataSource – On the Fly!

Following is the Example;

SELECT *  FROM 
(
     VALUES
    ('Test Product1', 'CW76548S', '5/12/2008'),
    ('Test Product2', 'CW98JK76', 6/12/2008'),
    ('Test Product3', 'CW909876', '7/12/2008')
) Product([Name],[ProductSKU],[CreatedDt])

Comments

# Row Constructor in SQL-2008 « KaushaL.NET

Monday, June 30, 2008 4:23 AM by Row Constructor in SQL-2008 « KaushaL.NET

Pingback from  Row Constructor in SQL-2008 « KaushaL.NET

# INSERT INTO..SELECT without specifying all columns | keyongtech

Pingback from  INSERT INTO..SELECT without specifying all columns | keyongtech

# re: Row Constructor in SQL-2008

Friday, January 01, 2010 6:25 PM by Eithertake

Simply Eat,unfortunately kill circle book none respect neighbour probably your lawyer smile control depend contribution several necessarily training largely name stop crisis blow club very how learn concern circle generation nevertheless trip retain colleague through signal suitable explain separate ride pattern channel gun shop remind terrible fact impossible path either expectation driver author carefully appear nice alright side almost way rock arise perform catch attractive shoot league mountain past hole name foundation quick advance result less somebody nation aid reform bit less my charge relief table membership test grant warm