I'm using vb.net 2005 to create a database application with SQL server 2000 as a backend.
Here's my design. All my tables have got a standard format for the primary key. Eg. My "tbl_offices" table has got the primary key set as OFF0000001, OFF0000002, OFF0000003 and so on.
Whenever i add a new record, i want a stored procedure to be able to:
1. Connect to the offices table
2. Retrieve the records ordered by primrary key
3. Increment the last primary key number by 1.
4. Return the next primary key in the right format.
I'm new to stored procedures, so i'm NOT fully aware of how this can be done. Once the stored procedure is created, how can i store the return value in a variable in VB?
It'll be great if i can pass the table name to the procedure as a parameter, cause then i can use this one procedure to generate and return primary keys for all my tables and store them in my form.
Appreciate any help. Thanks