Quantcast
Channel: SQL Server Data Access forum
Viewing all articles
Browse latest Browse all 4164

Query to insert record in another table based on 1 of 4 columns

$
0
0

So we have a table and in that table there are 4 columns that can contain values. In some cases no values for all 4 columns and in some all 4 columns populated and other instances, one or more populated.. 

So we need to insert a record into a different table and pull in one of those column values(not sure yet which one, meeting on it next week) but basically once they decide, we will need to find the appropriate value out of the 4 columns and insert that value into the other table.

So in this example below the first item has no values in either of the 4 columns, so for that we would default it to a value on insert. The other 2 records have both the first 2 columns with values, Ive added the "type" column because that is what we want to pull and insert into the other table.. so with the below example they chose they wanted the value from val1, but like i said its not 100% yet on if they are going to just go with one column(that will be easy), but if they want to decide based on other criteria, then id like to know how i can pull the correct value based on the initial criteria.



So in the other table we will be inserting 


Viewing all articles
Browse latest Browse all 4164


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>