Ad

Inconsistent DB Record Returns - Migrated AccessDB To SQL

- 1 answer

I have a table in my DB that has 2 bit fields, one called Active and one called Public..For all records Active and Public are both set to 1/true

When my query is

Select Top 1000 * from [NewsStory] WHERE Active = 1

I get all my records

When I change Active to Public it returns nothing...even though I can see all the Public fields displaying true the exact same as the Actives beside them.

Select Top 1000 * from [NewsStory] WHERE Public = 1

Is there something wrong with my DB conversion import? I don't understand at all why Active = 1 works but Public = 1 fails..

Thanks for any help

Ad

Answer

Public is a SQL Server reserved word. When you use a column name that is a reserved word you must embed it in brackets. For example, you should be using [Public] in your Select clause.

Ad
source: stackoverflow.com
Ad