I have a stored procedure that normalizes data and copies it to a new table structure.
The source data is contained in a SQL field varchar delimiter. The SP uses dynamic SQL, selects the data that does not already exist in the destination, normalizes, parses using a specified delimiter, inserts a record in the destination lookup table (if does not exist), and inserts the ID of the data from the lookup table in the destination reference table.
We are using SQL 2008 R2. I will provide a sample database with source and destination tables, the stored procedure for copying data, and a function for parsing the string using the delimiter. The current SP is not using the function and is using a cursor, which is very slow. I need the SP tuned, cursor removed, possibly use the provided parsing function to improve performance.
The current SP is approximately 100 lines and works correctly, but it needs tuning and review to assure compliance with Microsoft's SQL Best Practices standards.