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.
| 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 txtDescriptionFROM dbo.Element1_CodesWHERE (txtCostCenter = N'ab123')UNIONSELECT txtDescriptionFROM dbo.TempAllocationCodeWHERE (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} |
 |
|
|
|
|
|