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 |
|
gongxia649
So Suave
344 Posts |
Posted - 2006-08-31 : 09:46:34
|
| declare @errors table ( erroriD varchar (20), errorMessage varchar (100)) insert @errors select '1', 'unable to resolve address' ----------------------------------------------------------------------------------------------------------------------------------------declare @addressLookup table ( address varchar (100))insert @addressLookup select'water'union allselect'apple'----------------------------------------------------------------------------------------------------------------------------------------declare @exception table ( address varchar (100), errorID varchar (100))----------------------------------------------------------------------------------------------------------------------------------------declare @address table ( addressName varchar (100))insert @addressselect 'route 50 st'union allselect 'pine heaven st'union allselect 'banana st' union allselect 'apple st' union allselect 'sand st'----------------------------------------------------------------------------------------------------------------------------------------insert @exception (address, errorID) select substring(a.addressName, 1, charindex(' ', a.addressName)), e.errorIDfrom @address a, @errors ewhere substring(a.addressName, 1, charindex(' ', a.addressName)) not in(select address from @addresslookup al)and e.errorID ='1'select * from @exception----------------------------------------------------------------------If the addressName is not in the @addressLookUp table. This addressName should be insert into the @exception table with the correct errorID from @errors.i wrote the code but 'Pine heaven' and 'route 50 'is not showing. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-08-31 : 09:58:24
|
| I get pine, route, banana, sandwhen I run it.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
gongxia649
So Suave
344 Posts |
Posted - 2006-08-31 : 10:11:06
|
| i fixed it. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-08-31 : 10:16:33
|
quote: Originally posted by gongxia649 i fixed it.
I am impressed. Good work!Peter LarssonHelsingborg, Sweden |
 |
|
|
gongxia649
So Suave
344 Posts |
Posted - 2006-09-01 : 15:09:44
|
| declare @errors table ( erroriD varchar (20), errorMessage varchar (100)) insert @errors select '1', 'unable to resolve address' insert @errors select '2', 'wrong birthDATE' ----------------------------------------------------------------------------------------------------------------------------------------declare @addressLookup table ( address varchar (100))insert @addressLookup select'water'union allselect'us route 103'----------------------------------------------------------------------------------------------------------------------------------------declare @exception table ( addressException varchar (100), errorID varchar (100))----------------------------------------------------------------------------------------------------------------------------------------declare @address table ( addressName varchar (100))insert @addressselect 'route50 st street'union allselect 'sand circuit' union allselect 'water st'union allselect 'us route 103'union allselect '29 STREET' ----------------------------------------------------------------------------------------------------------------------------------------insert @exception(addressException, errorID) select CASE when substring(a.addressName, 1, len(a.addressName) - charindex(' ', reverse(a.addressName))+1) not in (select address from @addresslookup al)then substring(a.addressName, 1, len(a.addressName) - charindex(' ', reverse(a.addressName))) end,'1'from @address aselect * from @exception "us route 103" is in the @lookupTable. how do i write the code for it not to show up? |
 |
|
|
magnetica
Starting Member
36 Posts |
Posted - 2006-09-01 : 20:24:18
|
| Surely you just do a simple SELECT WHERE that field/s is not equal to "us route 103"!If this is not what you meant then plz say?!If you think you know it all?! You know nothing! |
 |
|
|
|
|
|
|
|