Basically I want to be able to intitially setup a variable for the WHOLE database.
For example I set this to 000001. The from various different procedures I would like to call this so it can be input into columns into the database. Straight after in the same procedure I would increment it by 1 so if called again it would be 000002.
When looking at variable it seems I can only set these up as local and within single tables or procedures. And looking at Cursors this is dependent on a SELECT statement ?
I know this syntax is wrong but it hopefully shows what I'm trying to achieve,
DECLARE @BATCHNO INT
SET @BATCHNO = 000001
In a seperate procedure,
UPDATE TABLE01
SET BATCH_NO = @BATCHNO
WHERE......
SET@ BATCHNO = BATCHNO + 1
I attempted to use IDENTITY but this increments on every row insert. I have batches of data which will be put into a table and once that's done I want to update a blank column with a specific batch number.
I hope this makes sense and someone can offer some sound advice.
For example I set this to 000001. The from various different procedures I would like to call this so it can be input into columns into the database. Straight after in the same procedure I would increment it by 1 so if called again it would be 000002.
When looking at variable it seems I can only set these up as local and within single tables or procedures. And looking at Cursors this is dependent on a SELECT statement ?
I know this syntax is wrong but it hopefully shows what I'm trying to achieve,
DECLARE @BATCHNO INT
SET @BATCHNO = 000001
In a seperate procedure,
UPDATE TABLE01
SET BATCH_NO = @BATCHNO
WHERE......
SET@ BATCHNO = BATCHNO + 1
I attempted to use IDENTITY but this increments on every row insert. I have batches of data which will be put into a table and once that's done I want to update a blank column with a specific batch number.
I hope this makes sense and someone can offer some sound advice.