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 |
|
ntn104
Posting Yak Master
175 Posts |
Posted - 2008-09-12 : 07:27:39
|
| Hello everyone,I have to delete duplicate name for one lawyer. However, there are many cases assigned to that lawyer in two different id. I want to delete one, but move cases from delete record to the other one. I wonder how I could do that won't loose assigned cases from delete lawyer, and move those cases to the other.For example: List1:LawyerID= 127332LawyerName= Allan GalThere are two cases assigned to this lawyerid (111222 and 222333)List2:LawyerID=127333lawyerName= allan GalimoreThere are also two cases assigned to this lawyerID (444555, and 555666)I would like to delete lawyer name listed in list1 and move two cases: 111222 and 222333 to lawyer listed in list2 since Lawyername in list2 is the correct name. How would I do and not loosing the cases assigned to that lawyer name.The above information came from two tables:First Table structure:LawyerID=127313lawyerName= Allan GalAddress= Ste 306, phila, pa 15222Second table structure:CaseID=111222LawyerID= 127313Thanks a bunch... |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-09-12 : 08:29:53
|
| update t2 setlawyerid = 127333from <table2> as t2where Lawyerid = 127332delete table1 where lawyerid = 127332Be One with the OptimizerTG |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
ntn104
Posting Yak Master
175 Posts |
Posted - 2008-09-12 : 08:58:00
|
quote: Originally posted by Peso What is "List 1" and "List 2"?http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxUpdate first all cases with "wrong" lawyer id to correct lawyer id.then remove wrong lawyer id from table. E 12°55'05.63"N 56°04'39.26"
At first, I thought the same thing, but lawyerid is assigned automatic by system. So I won't able to modify them. I think I will go with TG 's solution. I have not try yet..but I think that will solve the problem. |
 |
|
|
ntn104
Posting Yak Master
175 Posts |
Posted - 2008-09-12 : 09:14:45
|
quote: Originally posted by TG update t2 setlawyerid = 127333from <table2> as t2where Lawyerid = 127332delete table1 where lawyerid = 127332Be One with the OptimizerTG
Thanks TG...the query worked very well. It updated the record as I wanted. |
 |
|
|
|
|
|