HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

sysmessages table issue

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
issuesysmessagestable

Problem

I'm experiencing an annoying problem with a table named SysMessages in one of our databases.
When I run a select statement I don't get the contents of this table, but of the sys.sysmessages view in the master database.
A use [DBNAME] doesn't help, nor select * from [DBNAME].dbo.SysMessages.

I'm in the middle of a migration to a newer SQL Server version.
In SQL Server 2008 R2 I didn't encounter this problem with this database, but in SQL Server 2016 I'm not able to query my own SysMessages table.

Any help would be greatly appreciated.

Solution

This is the expected behavior for system compatibility views from SQL Server 2012+:


When referenced in a user database, system tables which were announced
as deprecated in SQL Server 2000 (such as syslanguages or
syscacheobjects), are now bound to the back-compatibility view in the
sys schema. Since the SQL Server 2000 system tables have been
deprecated for multiple versions, this change is not considered a
breaking change.


Example: If a user creates a user-table called syslanguages in a
user-database, in SQL Server 2008, the statement SELECT * from
dbo.syslanguages; in that database would return the values from the
user table. Beginning in SQL Server 2012, this practice will return
data from the system view sys.syslanguages.

You're probably going to have to fix your database to not use the same names as deprecated system tables (now system views in the sys schema).

Context

StackExchange Database Administrators Q#253735, answer score: 6

Revisions (0)

No revisions yet.