Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 better way of doing this

Author  Topic 

PeterG
Posting Yak Master

156 Posts

Posted - 2003-01-21 : 16:32:49
What I'm doing is grab the description from either the element1_codes or the tempallocationcode tables for a particular code. The code cannot be in both tables. Is there a better way of writing this?

SELECT txtDescription
FROM dbo.Element1_Codes
WHERE (txtCostCenter = N'ab123')
UNION
SELECT txtDescription
FROM dbo.TempAllocationCode
WHERE (txtCode = N'ab123') and txtSegment = 'Location'

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2003-01-21 : 17:00:26
If the row cannot be in both tables for a given code, UNION ALL will give slightly better performance, since there's no need for SQL Server to check for duplicates.

Jonathan
{0}
Go to Top of Page
   

- Advertisement -