Skip to content

Instantly share code, notes, and snippets.

@meganmcchesney
Last active December 14, 2015 05:59
Show Gist options
  • Save meganmcchesney/5039676 to your computer and use it in GitHub Desktop.
Save meganmcchesney/5039676 to your computer and use it in GitHub Desktop.
Insert Content into Content and ContentBridge use TSQL @@IDENTITY function
USE CurtDev;
GO
--Create new ContentID for every T-Connector part in the Content table
--use last inserted identity value as variable, id
INSERT INTO Content(text, cTypeID)
VALUES ('Simple plug and play design eliminates the need for cutting or splicing', 2);
SELECT @@IDENTITY AS contentID
GO
--define a variable to hold contentID from Content
INSERT INTO ContentBridge (catID, partID, contentID)
VALUES(Null, 55027, 294474);
SELECT @@IDENTITY AS contentID;
GO
@meganmcchesney
Copy link
Author

Each of these statements does the correct thing in my local db, however - I am inserting that value "55027" as a partID, which means running both statements 10 times for 282 parts. OUCH.
Any improvements you can suggest?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment