Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Inserting a record for each unique ID

$
0
0

Hey guys,

I have a pretty simple table used to control user options, with the following columns:

UserID, OptionType, OptionKey, OptionValue

There can be multiple records for each UserID, but each UserID won't necessarily have the same number of records, nor the same values.

What I need to do is make sure each UserID has the following record set against it:

OptionType = 5, OptionKey =2, OptionValue = 1

What's the easiest way to determine whether those values exist for each UserID, then insert them if they don't exist?

Thanks in advance


Viewing all articles
Browse latest Browse all 4871

Trending Articles



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