Reputation: 4727
I have a column in my query for which I want to use its alias name.
Currently it is looking like this:
SELECT U.first_name + ' ' + U.last_name UserName,
But I want to use it as like below
SELECT U.first_name + ' ' + U.last_name as User Name,
I tried but I got error as:
Incorrect syntax near the keyword 'User'.
Upvotes: 19
Views: 37020
Reputation: 228
Try This
SELECT U.first_name + ' ' + U.last_name as [User Name]
Upvotes: 14
Reputation: 15061
Double quotes for alias with a space.
SELECT U.first_name + ' ' + U.last_name AS "User Name"
Upvotes: 29