Syntax Error
Syntax Error

Reputation: 105

'Return' column name

My database tables have a Return column name. Now I'm having a problem whenever I'm trying to use it as condition. I'm also having an SQL error saying

Incorrect syntax near the keyword 'Return'

whenever I'm trying to do this SELECT Return FROM My_Table. I know I'm having that error because Return is one of the SQL syntax.

I've been searching on google, but I couldn't find the right keywords for that answer. Now, I want to know if is there any possible solution for that problem without renaming my column as it would cause a big effect on my system?

Upvotes: 0

Views: 88

Answers (2)

etsa
etsa

Reputation: 5060

In MSSQL you can use special characters or reserved words using [] or "".

SELECT 1 AS [RETURN], 2 AS "RETURN"

My suggestion: avoid, if possibile to use spec chars and res. words, and use plain simple names.

Upvotes: 1

Kesty
Kesty

Reputation: 479

Wrap the column name in bracket [Return].

select [Return] from table;

Upvotes: 3

Related Questions