SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Single Column Table
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ITTrucker
Starting Member

USA
45 Posts

Posted - 03/14/2013 :  13:37:15  Show Profile  Reply with Quote
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

USA
1974 Posts

Posted - 03/14/2013 :  13:50:38  Show Profile  Visit chadmat's Homepage  Reply with Quote
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
Starting Member

USA
45 Posts

Posted - 03/14/2013 :  14:07:48  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000