From the course: SQL Server 2008 Essential Training

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Creating transactions

Creating transactions - SQL Server Tutorial

From the course: SQL Server 2008 Essential Training

Start my 1-month free trial

Creating transactions

So I'm going to take this stored procedure a little further. The stored procedure I'm working with right now has three INSERT statements. It inserts an entry into the ProductModel table, it inserts a ProductDescription, and then it inserts a row that hopefully joins these two new rows together. Okay, so let's see it work. I'm going to flip over to where I have a prewritten piece of SQL that will execute that stored procedure, passing in ABCD123, and ABCD123 product description. So I execute that code. We get a result, the Command(s) completed successfully. To double check that, I have a little bit of code over here that's simply selecting the most recently added row to each of those three tables. I'll run that. And I get what I hoped for, that the first row that was added was for ProductModelID 139, so that primary key was generated, ABCD123. We have the Description that's under 2016, and ABCD123 product description, and then we have the third row that is joining 139 to the first row…

Contents