This is a discussion on inserting one query before another within the SQL Server forums, part of the Microsoft SQL Server category; --> I am having trouble inserting two queries...I am trying to insert an new item(pk) into a table in one ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I am having trouble inserting two queries...I am trying to insert an new item(pk) into a table in one query, and then inserting an item(fk) in another table that relates to the other item just created in the first. The problem is that in order for the second query to work, the first has to exist in the first table before it will work. Is there a way of running the first query first and then the next. Here is what I have: <cfquery name="q_insert" datasource="#dsn#"> INSERT INTO eccn (eccn_num, eccn_brief_descrip, eccn_full_descrip, eccn_reason_controlled) VALUES( '1D001', 'TEST', 'TEST INPUT AND SEARCH', 'TESTING THE INPUT AND SEARCH PERFORMANCE') </cfquery> <cfquery name="q_insert2" datasource="#dsn#"> INSERT INTO eccN_interrelationship (eccn_num, related_eccn_num) VALUES('1D001', '1B001') </cfquery> |