这里有一些SQL:
select T.*
FROM (
values ( '2014-05-30 17:26:32.749' , 'Casual shirt ' ) , ( '2014-05-30 17:26:32.749' , 'Casual shirt-White-Small ' ) , ( '2014-05-30 17:26:32.749' , 'Casual shirt-Blue-Medium ' ) , ( '2014-05-30 17:26:32.749' , 'Cords ' ) , ( '2014-05-30 17:26:32.749' , 'Bodysuit ' ) , ( '2014-05-30 17:26:32.749' , 'Cords-Black-29W x 28L ' ) , ( '2014-05-30 17:26:32.749' , 'Bodysuit-Black-Petit ' ) , ( '2014-05-30 17:26:32.749' , 'Cords-Brown-29W x 28L ' ) , ( '2014-05-30 17:26:32.749' , 'Classic pleated dress pant ' ) , ( '2014-05-30 17:26:32.749' , 'Classic pleated dress pant-Black-29W x 32L ' ) , ( '2014-05-30 17:26:32.749' , 'Dress shirt ' ) , ( '2014-05-30 17:26:32.749' , 'Dress shirt-White-15 ' ) , ( '2014-05-30 17:26:32.749' , 'Dress shirt-White-16 ' )
) T
;
它返回列" 1"和" 2"。如何更改它以便返回命名列?是否可以不使用sysdummy1?
答案 0 :(得分:6)
您可以将列名添加到T
:
select T.*
FROM (values ( '2014-05-30 17:26:32.749' , 'Casual shirt ' ) ,
( '2014-05-30 17:26:32.749' , 'Casual shirt-White-Small ' ) ,
( '2014-05-30 17:26:32.749' , 'Casual shirt-Blue-Medium ' ) ,
( '2014-05-30 17:26:32.749' , 'Cords ' ) ,
( '2014-05-30 17:26:32.749' , 'Bodysuit ' ) ,
. . .
) T(col1, col2);