Help with logic

Ah, yes (and of course I agree) but with the advent of [MyColumnName] allowing any characters, similar to when Filenames started allowing Spaces etc., then teh fact that it is possible to have spaces encourages their use - if we stick to a more narrow naming convention / rule we don't need "[" and "]" at all :slight_smile:

... my recollection is that "[" & "]" came about at the same time that Upsizing Access DBs to SQL Server could all be done with a Wizard, and with that came the spaces in column names - which Access never had a problem with in the first place.

For me, having to put "[" and "]" around a column name, because it contained a space/punctuation character, would be incentive enough not to use spaces!

When we mechanically generate code we only wrap columns with "[" & "]" if the column name contains non alpha-numeric (plus "_") characters, because I find their inclusion peppered in the code at every opportunity!! makes reading the code so much harder (SSMS code-generation is inclined to chuck "[" & "]" around everything "just in case")

e.g.

SELECT @SQLCommand = 
    CASE WHEN MyColumnName LIKE '%[^A-Z0-9_]%' 
        THEN QuoteName(MyColumnName) 
        ELSE MyColumnName  
        END
etc.