Are A1, A2, A3 meant to go into 1 ROW or multiple ROWS with the same Policy_Number? It would make more sense to have the Riders in a separate table where the combined Policy_Number (or Primary Key for that table) and each Rider_Code represents a distinct row. These tables could easily be joined on the policy_number (or Primary Key for that table), that way they could be returned by a simple query with an inner join.Create table #policy (ID int identity(1,1),Policy_Number int not null)INSERT INTO #policySELECT 100 UNIONSELECT 150 Create table #riders (ID int identity(1,1),PolicyID int not null,Rider_Code char(2) not null)Insert into #ridersSELECT 1,'A1' UNIONSELECT 1, 'A2' UNIONSelect 1, 'A3' UNIONSelect 2, 'A1' UNIONSelect 2, 'A2'Select * From #policy inner join #riders on #policy.ID = #riders.PolicyIDdrop table #policydrop table #riders/*ID Policy_Number ID PolicyID Rider_Code1 100 1 1 A11 100 2 1 A21 100 3 1 A32 150 4 2 A12 150 5 2 A2*/
If your intent is to place all rider codes in 1 column, that is trickier ...are the rider codes in a seperate table already linked by Policy Number or anything?
Poor planning on your part does not constitute an emergency on my part.