t-sqlsql-server-2000

Why does SQL Server 2000 treat SELECT test.* and SELECT t.est.* the same?


I butter-fingered a query in SQL Server 2000 and added a period in the middle of the table name:

SELECT t.est.* FROM test

Instead of:

SELECT test.* FROM test

And the query still executed perfectly. Even SELECT t.e.st.* FROM test executes without issue.

I've tried the same query in SQL Server 2008 where the query fails (error: the column prefix does not match with a table name or alias used in the query). For reasons of pure curiosity I have been trying to figure out how SQL Server 2000 handles the table names in a way that would allow the butter-fingered query to run, but I haven't had much luck so far.

Any sql gurus know why SQL Server 2000 ran the query without issue?

Update: The query appears to work regardless of the interface used (e.g. Enterprise Manager, SSMS, OSQL) and as Jhonny pointed out below it bizarrely even works when you try:

SELECT TOP 1000 dbota.ble.* FROM dbo.table

Solution

  • Maybe table names are constructed from a naive concatenation of prefix and base name.

    't' + 'est' == 'test'
    

    And maybe in the later versions of SQL Server, the distinction was made more semantic/more rigorously.

    { owner = t, table = est } != { table = test }