The VALUES Clause
SQL Server 2008 really expanded the capabilities of the VALUES clause in a select statement. I have read about this feature a number of times, and used it infrequently. Today I came across this posting and wanted to share the link with you. It has a few really cool examples of how to take advantage of the enhanced values clause.
In traditional SQL prior to SQL Server 2008 the values clause contained at most one list enclosed in parentheses, separated by commas. With the release of SQL Server 2008 you now have the ability to have multiple lists surrounded individually by parenthesis, each item separated by a comma, and each list separated by a comma.
SELECT C1, C2, C3, C4
from
(
VALUES (1,2,3,4),
(5,6,7,8)
)
as t(C1, C2, C3, C4)
See the VALUES clause here. Set 1 = (1,2,3,4) and the second set (5,6,7,8).
While this capability is nothing spactacular by itself, there are number of things you can do with it that are quite powerful. I hope you enjoy the link to the blog by Madhivanan.
Cheers,
Ben
$$SWYNK$$
Featured White Paper(s)
All-At-Once Operations
Written by Itzik Ben-Gan with SolidQ
SQL supports a concept called all-at-onc… (read more)
Featured Script
dba3_MedicalDB_SecurityObjectsAndData_Article
Legislated mandates are driving more implementations of row level security schemes . The article describes a generic DBMS bas… (read more)