Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Single Column Table

Author  Topic 

ITTrucker
Yak Posting Veteran

64 Posts

Posted - 2013-03-14 : 13:37:15
Is there anything special that I need to consider if I'm going to create a counter table that's single column, single row?

It's for creating unique serial numbers for labeling, so a program will determine that it needs 20 labels, and will do do a SELECT Count_Num FROM COUNTTABLE and then use that as a base to start the labels and then do an UPDATE COUNTTABLE SET Count_Num = (SELECT Count_Num FROM COUNTTABLE)+20.

So would it just be a:
CREATE TABLE dbo.COUNTTABLE
(Count_Num int)

chadmat
The Chadinator

1974 Posts

Posted - 2013-03-14 : 13:50:38
Well,

The select and update should be in the same transaction, or another transaction could get the same count_num (I am assuming that would be bad).

-Chad
Go to Top of Page

ITTrucker
Yak Posting Veteran

64 Posts

Posted - 2013-03-14 : 14:07:48
Good thinking, we only have one label printer and one person processing right now, but we'll be adding more at some point so probably a good idea. (As long as the labeling program can handle both at once...)
Go to Top of Page
   

- Advertisement -