DELETE and SELECT (Level 4)

DELETE and SELECT (Level 4)
SQL Server 6.x SQL Server 2000
Duplicate table names in the FROM clause of Microsoft® SQL Server™ version 6.0 DELETE or SELECT statement caused SQL Server to treat both table references as the same table. SQL Server discarded the reference to the second authors table in this SELECT example:
USE pubs
GO
SELECT * 
FROM authors, authors
GO

However, if the table names specified in the FROM clause of the DELETE or SELECT were not identical, SQL Server version 6.0 treated the two table references as two different tables as in this SELECT example:

USE pubs
GO
SELECT * 
FROM pubs..authors, pubs.dbo.authors
GO
Duplicate table names in the FROM clause of a DELETE or SELECT statement generate errors in SQL Server. Rewrite statements using aliases. Here is a SELECT example:
SELECT *
FROM pubs..authors AS a1, pubs.dbo.authors AS a2

USE pubs
SELECT *
FROM authors AS au1, authors AS au2

Expect different results as compared to SQL Server version 6.0. Rewrite DELETE and SELECT statements to use aliases in the FROM clause when referring to more than one instance of the same table.


Show: