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 |
|
aisha09
Starting Member
6 Posts |
Posted - 2010-07-16 : 16:27:52
|
| Table a has Vendor A datatable b has vendor B and VendorA dataI need to delete Vendor A data from table B which is present in Table A.Both the vndid are supposed to be the common field. But thereis a lot of mismatch in the data; for example vndid of Cheryl Smith is 0004 in Table Abut the vndid of Cheryl Smith in Table B shows 00004could you please help me with this query.Is der anywy we could do this with SSIS; as I am dealing with thousands of recordsThankYouAishaTable Avndid vndname2 Smith R4 julia5 nick6 daliaNull daleTable Bvndid vndname2 R smith7 Cheryl4 Julia5 Nick6 Dalia9 MARY10 dale11 joshua |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2010-07-16 : 17:39:14
|
something like:DELETE BFROM TableB AS BINNER JOIN TableA AS A ON B.vndid = A.vndid Sure you can also do this with SSIS in a number of ways. |
 |
|
|
aisha09
Starting Member
6 Posts |
Posted - 2010-07-16 : 18:20:28
|
| Hi i already deleted rows with the common vndid, but many records have vndid as null so i need to compare the two tables based on the vendorname. This is what i did. I created a table to concatenate the last name and firstname in table A.insert into C(name,vendorid) SELECT FirstName + ' ' + LastName as name, vendorid FROM A ORDER BY FirstName ASC; -------------------------------------------delete from B where vendorname in(select name from C join B on C.name = b.vendorname )But there seems to be no use. Please help. |
 |
|
|
CrazyT
Yak Posting Veteran
73 Posts |
Posted - 2010-07-16 : 19:52:19
|
| you have a "smith r" and and "r smith" in the other table -- that a typo or are the fields you comparing backwards? |
 |
|
|
aisha09
Starting Member
6 Posts |
Posted - 2010-07-16 : 20:11:14
|
| Thats not a typo. We gt the data in that format; with so much if differences in the name; Actually its the same name but written backwards. |
 |
|
|
|
|
|