sql server ce - Why do my "safety brackets" actually PREVENT this SQL from Working? -
i've got code had apparently needed have brackets applied sql statement due column named "name"; "fixed" code was:
dynsql = string.format("delete platypi duckbill = '{0}' , [name] = '{1}'", tmptype, tmpstr); unfortunately, code not doing job - record not being deleted. removing brackets around "name" column:
dynsql = string.format("delete platypi duckbill = '{0}' , name = '{1}'", tmptype, tmpstr); ...caused work. why adding "suspenders" column name cause column unrecognized? answer question here indicates encasing column names (and table names) in brackets safe way avoid naming collisions other objects/database keywords , such.
when sql brackets fails, no err msg displayed, doesn't work.
note, though, inconsistent; sql contains "[name]" opposed "name" works fine - iow, same sql statement same val "duckbill" different 1 "name" works; "valerie" fails (when column named "name" bracketed).
here go. looks brackets aren't supported. use double quotes instead.
http://technet.microsoft.com/en-us/library/ms174147(v=sql.110).aspx
Comments
Post a Comment