Hi I have created a cursor based loop to insert all possible medical conditions for each ID. As below. The ID are located in another SQL table and the conditions are listed in the insert statements. DECLARE @Parameter intDECLARE IDs CURSOR LOCAL FOR select ID from MyIDtableOPEN IDsFETCH NEXT FROM IDs into @ParameterWHILE @@FETCH_STATUS = 0BEGINEXEC('INSERT INTO MYConditionTable (ID, Condition)VALUES (' + @Parameter + ', ''Allergy'');INSERT INTO MYConditionTable (ID, Condition)VALUES (' + @Parameter + ', ''Asthma'');INSERT INTO MYConditionTable (ID, Condition)VALUES (' + @Parameter + ', ''Colitis''); ') FETCH NEXT FROM IDs into @ParameterENDCLOSE IDsDEALLOCATE IDs
I wondered if anyone knew a better way to do this perhaps with a for each loop. thanks