|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Insert rows from Table A not in table B ??
I need help with the following query. How do I construct the following SQL query:
I need to be able to get all rows from Table A where the ID key is not in Table B EX: columns for both tables: ID (Key) Code Name Many thanks !!
__________________
:P
|
|
#2
|
|||
|
|||
|
Code:
select * from a where not exists (select * from b where a.id = b.id) |
|
#3
|
||||
|
||||
|
THANKS
Ok now if I want to insert those values into table A ?? I've got the following: (TA = table A, TB = table B) insert into TA SELECT TB.Id,TB.Code,TB.Name from TB LEFT JOIN TA ON TB.Id = TA.Id WHERE TA.Id IS NULL It's working, but is there another way ? |
|
#4
|
|||
|
|||
|
If it's working, why do you need another way?
|
|
#5
|
||||
|
||||
|
Quote:
Just curious ![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Insert rows from Table A not in table B ?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|