I am passing a delimited string to a stored procedure that is composed by empId|ProductId + a comma as delimiter with the purpose of filling a link table. using SQL Server 2008
EmployeeOrderLink Table to be filled
EmpId
OrderId
ProductId
Example of a possible key
MyKeyIds="EmpId|ProductId,
EG 2232|33,4555|111,43343|65 etc...
How do I loop through the string split it and insert into the table eg
while MyKeyIds ???
Logic --PLEASE NOTE THAT EACH KEY IS COMPOSED BY 2 VALUES
AND SEPARATED BY THE COMMA.DELIMETER IS USED TO SEPARATE THE INNER VALUES OF THE KEY
@myEmpID=--Get EmpId from split string
@myProductId =Get productId from split string
INSERT EmployeeOrderLinkend(EmpId,OrderId,ProductId)
VALUES(@myEmpID,@OrderIdPassedAsParamInSP, @myProductId)
END
Any suggestion on how to split the above key and extract the appropriate values? Thanks a lot