Reputation: 2388
I have a SQL table, let's call it "Table A", which has several rows of data. I then have a temp table called "Table b" that has one row of data. I want to be able to do a sql insert so that if Table A Column 1 is null, it will insert Table B Column 1's value.
So I'd wind up with something like this:
Table A
Col1 Col2 Col3
23 John Smith
23 Sam Jones
23 Jim Ham
Table B
Col1
23
Can someone explain how I might go about doing this? Any help will be appreciated.
Upvotes: 1
Views: 217
Reputation: 135848
You say insert, but I think you're asking for an update.
update TableA
set Col1 = (select Col1 from TableB)
where Col1 is null
Upvotes: 1
Reputation: 274738
update tableA set col1 = (select col1 from tableB)
where col1 is null
Upvotes: 0