Hello Folks,

You may have heard this name earlier. But I am sure; many of you don’t have enough information about the Row Constructor. Well don’t worry; I am going to give you some heads up:

  • The Row Constructors is a new feature for SQL Server 2008.
  • It provides a convenient way to supply hard-coded values directly in a subquery.
  • The VALUES clause is wrapped in parenthesis, as in every hard-coded row. It requires an alias and a column alias list, also in parenthesis.
  • So, the Row Constructors can be used in the FROM clause and joined just like any other type of data source.
  • The following examples will make this more clear to you…This is an example which shows Simple Use of Row Constructors-

The results can be seen as:

1_SQL_Server_Do_You_Know_Row_Constructors

  • We can also use the ALL clause, where it must be true for all every value. So, you can see with the example:

The result can be seen as:

2_SQL_Server_Do_You_Know_Row_Constructors

While dealing with the ALL condition, keep in mind that if there happens any value to be null, then no values being returned.

  • We can use the SOME and ANY condition, which returns true if the condition is met for any values in the subquery result set. For e.g.,

The result can be seen as:

3_SQL_Server_Do_You_Know_Row_Constructors

Well this was all about row constructor.

Hope you liked it :)

 

Regards

Piyush Bajaj

Like us on FaceBook Follow us on Twitter | Join the fastest growing SQL Server group on FaceBook

Follow me on Twitter  |  Follow me on FaceBook