"I need to figure out how to run a query and get a recordset row.
With the data from that recordset I need to create create a new row changing the primary key.
If you want table names or column names or an entire WHERE clause in your variable it gets more complicated. The second step is to update the existing record with the new status value.
Now we have the primary key of the record we wish to update and the new status value. We'll use an INSERT/SELECT statement that looks like this:: Notice that we didn't need to insert a value for PKValue since it's an identity column.
I used my parameter in the WHERE clause to indicate which record I wanted.
Let's assume your table looks like this: I'll need to pass two parameters to our stored procedure.
The first is the old primary key value and the second is the new status.
You can generally use a variable either side of the equal sign in a WHERE clause.
I'm assuming that the PKValue field is an identity column so I don't need to supply it a new value.
Our create prodedure statement will look something like this: Notice that each parameter's data type is defined along with the parameters.