question

conviva avatar image
conviva asked

Special characters in view column name

Recently I came across a view with column names containing a #, a space, and other "special" characters. So I asked and the answer was that a view was something used before for reporting and since that was what we believe that is what was intended we use this to make the report columns descriptive. As a developer I can redactor these columns to be anything I want and will be handled correctly so no big deal, just never have seen this done. Now I am not a SQLDB by any stretch of the definition but this has a code smell to it and as a developer I would tell someone to fix it and never do that again :-). So enlighten me, note I will never do this as I believe it is bad practice, I would like to understand if this is a common practice or even a best practice.
views
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Fatherjack avatar image
Fatherjack answered
You are 100% right, this is a 'code smell' - while it might work OK it is an incident waiting to happen. I would move to have column names in any SQL Server object to have no special characters (and I'd include the space as a special character). For user information then special characters can be added at the presentation layer (application / report / etc)
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.