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 |
|
sgtglok
Starting Member
2 Posts |
Posted - 2004-11-05 : 16:56:47
|
| Hi all,Here is my situation and problem. I have a historic 'flat' table I am converting from Paradox. It has a unique identifier CASE_ID for each record. Each record also has REPORTER_ID, REPORTER_NAME and REPORTER_ADDRESS columns. I need a REPORTERS table with unique records. The problem is REPORTER_ID is not unique or sometimes is NULL. A) Global tableCASE_ID REPORTER_ID REPORTER_NAME REPORTER_ADDRESS1001 NULL A 123 Nowhere Street1002 NULL A 123 Nowhere Street1003 NULL B 345 Somewhere Avenue1004 NULL B 345 Somewhere Avenue1005 NULL B 345 Somewhere Avenue1006 1234 C 999 Another Place1007 1234 C 999 Another PlaceB) REPORTERS tableREPORTER_ID REPORTER_NAME REPORTER_ADDRESS1234 C 999 Another PlaceTEMP1 A 123 Nowhere StreetTEMP2 B 345 Somewhere AvenueThe way I figure, I need to first extract those records with REPORTER_ID=NULL into a temp table and then assign EACH GROUP of records with same REPORTER_NAME and REPORTER_ADDRESS a UNIQUE REPORTER_ID. I need some help with query construct. The table is pretty large, so there could be 2000+ occurances of the same REPORTER_NAME and REPORTER_ADDRESS that I need to assign the same REPORTER_IDAny help would be appreciated. Thanks |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-11-05 : 17:04:17
|
Create Table #tempTable(Reporter_Id int identity(seedVal,1),Reporter_name varchar(100),Reporter_Address varchar(100))Insert Into #tempTableSelect Distinct Reporter_Id, Reporter_Name, Reporter_Address From <global table>Where Reporter_IdInsert Into Reporters Select * From #tempTableUpdate <Global Table>Set Reporter_Id = #tempTable.Reporter_IdFrom <Global Table> Inner Join #tempTableOn <Global Table>.Reporter_Name = #tempTable.Reporter_Nameand <Global Table>.Reporter_Address = #tempTable.Reporter_AddressCorey |
 |
|
|
sgtglok
Starting Member
2 Posts |
Posted - 2004-11-05 : 17:11:33
|
| Wow, this was some quick response!!Looks like it might just work. Many thanks!!! |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-11-06 : 00:24:55
|
hope it does work out for you! Corey |
 |
|
|
|
|
|