Win Surprise Gifts!!!
Top 5 Contributors of the Month
Post New Question
Subscribe to Forum
What is the use of Row Constructor in Sql Server 2008?
September 11, 2010
Can any one tell me the use of Row Constructor in Sql Server 2008?
Will be happy if you post with sample codings...
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.
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.
INSERT INTO #TempTable
FROM OPENQUERY(ServerName, 'exec StoredProc')
Above mentioned same query can be now written with simpler statement as described here.
INSERT INTO #TempTable
Note that this does not work with real tables or any other objects. This feature is only available to load temp tables.
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
-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
To post reply
Related Questions Related Questions
Upgrade from SQL Server 2000 to SQL Server 2008
Performing search on MS SQL Server 2008 database
Taking incremental backups from MS SQL Server 2008 Database
Copying Data from SQL Server 2008 to SQL Express
SQL Server 2008 - Table - Clarifications
How to install softwares on client computer from server computer in Visual Basic.Net 2008.
What are the new features that we have in Sql Server 2008?
how many nested levels are there in Sql Server 2008 for Stored Procedures?
How to deploy on a windows web 2008 dedicated server the VS 2010 ASP.NET simplest template ?
Is it possible to restore SQL Server 7 Back up in SQL server 2008 or 2005?
Latest Forum Questions From The Same Category
Help to get SQL output
how to restore my sql database from my hosting provider?
SQL query to update date range
Add allowance to employee table is wrong or true according to my case
how to remove trailing zeroes in a decimal in sql server
Required Union All Result in two different column
Sql Multiple table data retrival
Table Translation records
How select huge Data from sql without take long time?
Passing using parameter in store procedure get the top3 record from the table
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more
Quick Links For Forum Categories:
Hall of Fame
Terms of Service
Tell A Friend