Sumafu Sumafu - 17 days ago 6
SQL Question

Strange SQL-Statement

I just found an SQL-Statement with a syntax I never seen before. And I found nothing in the internet about this syntax. Does anybody knows what [field] means?

SELECT 'Customer' AS Tablename
, [Ct_ID] AS ID
, [Ct_Name] AS Name
FROM Customer

Answer

In MS TransactSQL (aka SQL Server), square brackets are used around field names that would otherwise not be valid (reserved words, names with spaces or other special characters).