.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

What is the use of Row Constructor in Sql Server 2008?

Posted By: Deco     Posted Date: September 11, 2010    Points:2   Category :Sql Server
Can any one tell me the use of Row Constructor in Sql Server 2008?

Will be happy if you post with sample codings...

Author: Naim Khan             
Posted Date: September 13, 2010     Points: 5   

While playing with SQL Server 2008 I found new feature of "Row Constructors", where I can load temp table from stored procedure directly.

hello friend,

Look at the following SQL where I have to use OpenQuery from server to itself creating loopback server and execute stored procedure and insert into temp table.

FROM OPENQUERY(ServerName, 'exec StoredProc')

Above mentioned same query can be now written with simpler statement as described here.

EXEC StoredProc

Note that this does not work with real tables or any other objects. This feature is only available to load temp tables.

Naim Khan

Software Developer
Author: Rajshree             
Posted Date: September 17, 2010     Points: 5   

Don't you feel boring sometimes when you have to write an script to insert multiple rows in a table and you do not have any other choice except writing multiple insert statements? In one of my previous posts I showed a way to insert multiple rows by using UNION ALL but wait! there is another way available in SQL Server 2008 called Row Constructor which is an ANSI terminology for pseudo table of rows.
It is actually a way to provide a set of row values in one statement. Following example will help you understand better. Please note that this example can work only on SQL Server 2008 or above:

-Switch to tempdb
Use tempdb

-Create a test table in temdb
Create table tblCountries (id int, country varchar(50)

-Inserting multiple values
Insert into tblCountries (id,country)
(1,'USA'), -Row 1
(2,'UK'), -Row 2
(3,'France') -Row 3

-Now select, you will get 3 rows
Select * from tblCountries

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend