My problem is with @officeident. In that for each new record inserted into LicenseHolder it has the same officeident.. this SQL inserts into OfficeID the value 1495 for every row. Which was the last identity inserted. Which does not create the parent child relationship.
I think I should be researching a for next cursor. For every insert into Office a new row is then added to LicenseHolder so I can build the relationship. Or if there is a simpler way or any help would be greatly appreciated.
DECLARE @officeident INT insert into [MembersDB].[dbo].[Office] ([AddressLine1] ,[AddressLine2] ,[State] ,[PostCode]) select [OfficeMailingAddr],[OfficeMailingAddr],[state],'1' FROM [Members].[dbo].[Main] SET @officeident = SCOPE_IDENTITY() INSERT INTO [MembersDB].[dbo].[LicenseHolder] ([Name] ,[Email] ,[Mobile] ,[OfficeNumber] ,[LicenseHolderTypeID] ,[PartyTypeID] ,[OfficeID]) SELECT [OfficeOf] ,[OfficeEmail] ,[Phone] ,'1234' ,'1' ,'1' ,@officeident --I want like this to be different for each row. FROM [Members].[dbo].[Main]