Adam MK
Adam MK

Reputation: 21

Displaying values for non-existent column

In Oracle, I can define a value for a column that doesn't exist in a table, like

SELECT 
    C.CUSTOMER_ID, ' ' CUSTOMER_PHONE , 'JAMAICAN' CUSTOMER_NATIONALITY.

I need to know if I can achieve the same in SQL Server.

Upvotes: 2

Views: 114

Answers (1)

S3S
S3S

Reputation: 25132

Yes, very similar...

SELECT 
    C.CUSTOMER_ID, 
    ,CUSTOMER_PHONE = ' ' 
    ,CUSTOMER_NATIONALITY = 'JAMAICAN' 
FROM
   YourTable

You will also see this column aliasing with the word AS.

SELECT 
    C.CUSTOMER_ID, 
    ,' ' AS CUSTOMER_PHONE  
    ,'JAMAICAN' AS CUSTOMER_NATIONALITY  
FROM
   YourTable

Upvotes: 3

Related Questions