Table Value Constructor & Transact SQL

Background

SQL-92 extends the traditional semantics for providing values to SQL.

Code

UNION


select 
       'CA' as [stateAbbrev]
      ,'California' as [stateName]

union all

select 'FL' ,'Florida'  

union all     

select 'IL' ,'Illinois'  

union all 

select 'NY' ,'New York' 

union all

select 'TX' ,'Texas'  

 

Table Value Constructor

 


select  
         [stateAbbrev]
       , [stateName]

from
    (

        VALUES

          (  'CA' ,'California' ) 
        , (  'FL' ,'Florida'  )     
        , (  'IL' ,'Illinois'  ) 
        , (  'NY' ,'New York'  )
        , (  'TX' ,'Texas'  )

    ) 
    tblV
    (
         [stateAbbrev]
       , [stateName]
    )



Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s