Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 26th, 2005, 03:19 AM
Authorized User
 
Join Date: Aug 2005
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are there easier way to do this?
I use MS SQL Server
So it would be, ie. 61
                    62
                    63
                    ..
                    ..
                    610
                    ...
                    6100
                    6200
                    ....
 
Old September 27th, 2005, 06:52 AM
Registered User
 
Join Date: Sep 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Do the product ids have meaning outside the database? If so it is
probably better to use another field as the primary identifier that
does not have meaning outside the database and so can be an integer.

However, whether you do that or not I think that the best way to
generate the next number is to use a transaction in the insert stored
procedure and first SELECT @NewId = MAX(PID) + 1 FROM Product; and then insert @NewId into the PID for the new row.

I hope this helps.
 
Old September 29th, 2005, 08:45 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think your making things complicated for no reason. Why not use a normal key that is an int and have another field with a unique index with your 6.1 type stuff? You can populate the 6.1 vield with a view automatically if you want. Another thing to ask yourself is do you want to have to go to 6.99 before getting to 7.00?






Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Design: Foreign Key to Multiple Primary Keys? kalel_4444 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 10 May 8th, 2008 04:14 PM
SQL to identify the primary key in a table? dbayona SQL Server 2005 1 October 24th, 2007 02:33 AM
SQL Server Primary Key Incrementer tclancy SQL Server 2000 13 March 23rd, 2006 09:44 AM
How to Auto Generate ID (Primary Key) SQL database havering SQL Server 2000 9 December 1st, 2004 10:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.