Incrementing Counters
Table Value |
|
Fetching New Record Number for a give Table Name |
Before you add any records, you need to fetch
the "Record Number" from the Counters Table, and
update the Counters Table
-
The name of table is "Counters"
-
Fetch the record which belongs to Consultants (Candidates) Table. It will be LIKE 'CSnnnnnnnn', so you are fetching using the following sql
SQLStmt = "Select * From Counters Where TableName = 'Consultants'"
-
The NewNumber will be 'nnnnnnnn' + 1, which is updated back to the Counters Table into the field "CurCount".
Ex, if the current value is 'CS00000035', then the new number will be 'CS00000036'
SQL
STORED PROCEDURE:
Please find the following link to download the User defined T-SQL store procedure.
PROCEDURE to use out site the Trigger:
Link: Fetching New Record Number for a give Table Name
PROCEDURE to use with in the Trigger:
Link: Fetching New Record Number for a give Table Name in the Trigger
Note: Current stored procedure can generate a New Record Number for a given table. The generated Record Number ID can be used to create the new record in that particular table.