I'm trying to write an insert statement which would get data from an array.
I have two variables, one is BusinessID and one is BusinessType. A business can have multiple types. For example BusinessType = (1,2,3,4,5), however BusinessID would only ever be a single number e.g. BusinessID = 1
Is there a function in mssql to be able to do something like;
for BusinessType in BusinessType
insert into Business
Values(BusinessID,BusinessType)
This would ideally give me the result
BusinessID BusinessType
1 1
1 2
1 3
1 4
1 5
INSERTstatements.Businessshould contain records where each record represents a "business" (whatever this is in your context). If that tableBusinesshas a column calledBusinessID, then this should be the ID to identify one record (or one "business"). It doesn't seem to make sense to have multiple records inBusinessthat have the sameBusinessID. It seems you are trying to build a kind of bridge table combining "businesses" with "business types". You should think over your database design or at least your naming pattern.