The following query runs at least 30 minutes in Sybase Adaptive Server Anywhere 9 (got tired of waiting), but only takes a few seconds in SQL Server 2000.
SELECT n.names_id, n.first_name, n.last_long_name, n."address", n.address_2, n.company
FROM names n WHERE EXISTS (SELECT 1 FROM names n2
WHERE IsNull(n.last_long_name,'') = IsNull(n2.last_long_name,'')
AND IsNull(n.first_name,'') = IsNull(n2.first_name,'')
AND n.names_id <> n2.names_id)
ORDER BY n.last_long_name, n.first_name
I am querying a table of names with 162,000 records. I have rewritten the query using a join instead of the subquery, but either way it takes forever.
Any help is appreciated.