Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Multiple Table Insert Expand / Collapse
Author
Message
Posted Sunday, November 16, 2003 12:00 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, March 25, 2004 5:05 AM
Points: 5, Visits: 1
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/nraghavendra/multipletableinsert.asp


Post #18257
Posted Tuesday, November 18, 2003 2:27 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, December 12, 2005 4:42 AM
Points: 5, Visits: 1
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



Post #87249
Posted Friday, February 22, 2008 10:11 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 22, 2008 9:57 PM
Points: 2, Visits: 4
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.....
Post #459397
Posted Monday, December 19, 2011 6:11 PM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Sunday, April 13, 2014 5:45 PM
Points: 519, Visits: 1,209
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?
Post #1224110
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse