Error with emojis in column aliases

Matthew McCord 0 Reputation points
2023-03-13T12:51:46.7866667+00:00

I'm having a problem in SQL server when using emojis in column aliases:

with [cte] AS (
SELECT
NULL AS [πŸ•]
,NULL AS [πŸ•πŸ€’]
)
SELECT [πŸ•] FROM [cte]

Msg 8156, Level 16, State 1, Line 1
The column 'πŸ•πŸ€’' was specified multiple times for 'cte'.

Completion time: 2023-03-13T08:44:20.3825178-04:00

Certain emojis work as expected. This query executes successfully:

with [cte] AS (
SELECT
NULL AS [πŸ•]
,NULL AS [πŸ•β€]
)
SELECT [πŸ•], [πŸ•β€] FROM [cte]

Tested on SQL Server up to version 2022: 16.0.1000.6

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,838 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Olaf Helper 44,741 Reputation points
    2023-03-13T13:23:49.9166667+00:00

    And what could that be good for?

    Anyway, see Rules for Regular Identifiers, emoji's are not allowed in object/column names.


  2. Matthew McCord 0 Reputation points
    2023-03-13T16:49:38.2133333+00:00

    Changing DB collation from SQL_Latin1_General_CP1_CI_AS to Latin1_General_100_CI_AS_SC resolved this issue.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.