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 July 6th, 2007, 04:47 AM
Registered User
Join Date: Jul 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Irfan_Lateef Send a message via Yahoo to Irfan_Lateef
Default problem Int to Autonumber

       I m using Microsoft SQL and my IDs are in 1001, 1002, 1003...and so on. How can I int this IDs? Like 1001 +1=1002? Please help...
But I don't want to use auto number, I want to use just Int or Varchar field not auto number please help me reply me as soon as possible

Old July 6th, 2007, 11:52 PM
Friend of Wrox
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts

Why don't you want to use auto number starting at 1001? And what are you going to do at 9999?

--Jeff Moden
Old July 9th, 2007, 10:57 PM
SQLScott's Avatar
Wrox Author
Join Date: Dec 2004
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts

If you don't want to use autonumber, you have several options:

1) have your application grab the last (largest) number, add 1, and use that as the new ID. That way you can use an int or varchar.
2) Put an insert trigger on that table that basically does the same thing (grabs the largest number, adds one, and saves that as teh new ID).

The downside to doing it this was is that you have to write all the "New ID" logic. Not easy. What happens in the case where two people ask for the largest number at teh same time? They'll both get the same "new ID".

What is your reasoning for not wanting to use autonumber? You can set the seed of the autonumber to anything you want. It doesn't have to start at 1. You can start it at 1000 if you like.

Scott Klein
Author - Professional SQL Server 2005 XML

Similar Threads
Thread Thread Starter Forum Replies Last Post
autonumber problem in Access Pat Crotty Access VBA 2 September 6th, 2006 10:37 AM
Autonumber problem mankoti_mankoti2000 Access 6 August 29th, 2006 12:28 AM
AutoNumber causes problem. myself Classic ASP Professional 1 July 10th, 2006 03:35 PM
problem inserting a record with autonumber phytos VS.NET 2002/2003 2 January 16th, 2006 07:14 PM
Want to reiterate on my char to int problem CNewbie C++ Programming 0 April 2nd, 2004 12:47 AM

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