This is probably super basic but I've never built a procedure where I'm writing to a table where I need to pull the next id. Can someone walk me through how to find the next id, assign it on the insert, and then make sure that the next id table gets updated?
Thanks in advance!
Depends: does this procedure insert individual rows, or does it need to insert a number of rows at once?
For the former, I believe that the stored procedure [dbo].[AP_GET_NEXTID_function] is the officially sanctioned method to acquire an id while incrementing the T_NEXT_ID table.
If you want to update a number of rows at once you can also use this with an increment, but will need to sort out distributing the ids for insertion yourself (I have some code for that if you'd like).
I'm looking to insert multiple rows at once. Basically, I'm copying info from one place to another because it needs to live in two places. Would love to see the code you use. Thanks!
I do this a fair amount: typically I create rows in a temporary table before inserting them into the table in question, which sounds like a good option if you're copying info from one place to another. Generally what you should do is:
Thanks!