USE FencoDW
GO
DECLARE @ID INT, @PR varchar(50)
DECLARE @getID CURSOR
SET @getID = CURSOR FOR
SELECT [Load Number], [Primary Reference(s)]
FROM Accounting.TransplaceLoadInfo
OPEN @getID
FETCH NEXT
FROM @getID INTO @ID, @PR
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @ID
PRINT @PR
INSERT INTO dbo.T1 ([Load Number], [Primary Reference(s)])
SELECT @ID, [Val] from dbo.ParseCSV(@PR, ',')
FETCH NEXT
FROM @getID INTO @ID, @PR
END
CLOSE @getID
DEALLOCATE @getID
GO