How to Create an array or 2 columns table using select - select from list of values - row/column constructor

in #sql4 years ago

----------------Syntax---------------------------

SELECT

FROM
(
Values
( ValueForField1, ValueForField2,..., ValueForFieldN ),
( ValueForField1, ValueForField2,..., ValueForFieldN ),
( ValueForField1, ValueForField2,..., ValueForFieldN ),
( ValueForField1, ValueForField2,..., ValueForFieldN ),
( ValueForField1, ValueForField2,..., ValueForFieldN )
) AS TempTableName ( FieldName1, FieldName2, ..., FieldNameN )
-------------------Example-------------------

select * from (values ('1',2),('2',3) ) as a (datacol,datacol2)

Or same simmilar array could be built using below method

SELECT * FROM (VALUES('Row1'),('Row2'),('Row3')) as tbl1 ([ColumnFieldName1])
,(VALUES('NoOfColumns1'),('NoOfColumns2')) AS z([ColumnName2])

Coin Marketplace

STEEM 0.19
TRX 0.25
JST 0.038
BTC 97262.35
ETH 3392.76
USDT 1.00
SBD 3.02