How to write select with values in SQL server

This is a example of Select statement without from clause with multiple rows.

VALUES ( <row value expression list> ) [ ,...n ]   
  
<row value expression list> ::=  
    {<row value expression> } [ ,...n ]  
  
<row value expression> ::=  
    { DEFAULT | NULL | expression }

This code will create a data set with two columns named c1 and c2 and two rows.

SELECT *
  FROM (VALUES (1,2)
             , (3,4)
       ) t1 (c1, c2)

	select * from (
	VALUES ('Helmet', 25.50),  
       ('Wheel', 30.00)  
       ) ab(a,b) ;  
Spread the love

Leave a Comment