Providing an alias with a space in sql

I have a column in my query for which I want to use its name alias .

Currently, it looks like this:

SELECT U.first_name + ' ' + U.last_name UserName,

But I want to use it as below

SELECT U.first_name + ' ' + U.last_name as User Name,

I tried but got an error:

Incorrect syntax next to the keyword "User".

+4
source share
2 answers

Double quotes for an alias with a space.

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

try it

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

Source: https://habr.com/ru/post/1653117/


All Articles