Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Boosting Primary Keys

Database Field Output

Boosting Primary Keys

by  webmigit  Posted    (Edited  )
I recently created a sort of check drafting system in cold fusion.. but that's not important, what is important is the check numbers.

When you get a new account from the bank, they ask you what check # to start out at.. Nobody wants to start at 1.. Businesses distrust low-numbered checks.

I had the same feeling about my check drafting system, after all the numbers are only for your identification purposes anyway.. they're not anything super special.

Well there is of course just adding to the number in the output..

#Evaluate(chknum + 9300)#.. Now that's always nice but for consistency I'd have to do it everywhere, and then if osmeone entered a check number, I'd have to subtract the added amount.

Well.. Check numbers should be unique and of course databases have primary keys which are also instended (and thoroughly enforced) to be unique. So that's what I used.. But I didn't want to start at 1.. and I didn't want to have thousands of "fake" rows..

But I found out (this works in sql server at least) that if you setup another primary key on your table and change the original to regular int/numeric/number whatever, and then for your first row put in the desired starting number, and then go back and delete the new key and restore the properties to the old one.. That that's where the number starts.

This isn't a big tip.. Its not going to make or break a website, but it saved me a lot of time.

Thanks,
Tony Hicks
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top