• I have made a copy of Narayana's sproc on my Northwind db. Also, I've made two copies of Employees table calling them Employees1 and Employee2.

    When I exec the sp_multi_inserts sproc on Northwind database I get the following error:

    Msg 156, Level 15, State 1, Line 2

    Incorrect syntax near the keyword 'SELECT'.

    Execute statement looks as follows:

    USE Northwind

    GO

    DECLARE @DELIMITER AS VARCHAR(200)

    DECLARE @INSERT_PART AS VARCHAR(2000)

    SET @DELIMITER = 'ZZZYYYXXX'

    SET @INSERT_PART = 'WHEN EMPLOYEEID < 5' + @DELIMITER + 'INTO EMPLOYEES1 (LASTNAME, FIRSTNAME

    VALUES (LASTNAME, FIRSTNAME)' + @DELIMITER + 'WHEN EMPLOYEEID >4' + @DELIMITER + 'INTO EMPLOYEES2 (LASTNAME, FIRSTNAME) VALUES (LASTNAME, FIRSTNAME)'

    EXEC SP_MULTI_INSERTS 'SELECT EMPLOYEEID, LASTNAME, FIRSTNAME FROM EMPLOYEES', @INSERT_PART, @DELIMITER, ''

    What is wrong with how I'm executing the sproc?