November 16, 2003 at 12:00 am
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/nraghavendra/multipletableinsert.asp
November 18, 2003 at 2:27 am
Thanks for code and explanation. I guess i could put the conditions in a separate table and use the data to create the parameters required for this stored procedure.
Edited by - rajenshah on 11/18/2003 02:28:04 AM
February 22, 2008 at 10:11 pm
I have problem with store procedure, I cant use strord procedure
in my project.....
SO can u tell me how to insert multiple table by code not procedure.....
December 19, 2011 at 6:11 pm
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?
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply