HEEN
HEEN

Reputation: 4727

Giving alias name with space in sql

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

Answers (2)

taotechnocom
taotechnocom

Reputation: 228

Try This

SELECT U.first_name + ' ' + U.last_name as [User Name]

Upvotes: 14

Matt
Matt

Reputation: 15061

Double quotes for alias with a space.

SELECT U.first_name + ' ' + U.last_name AS "User Name"

Upvotes: 29

Related Questions