User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 361,863 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,578 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:
Views: 2870 | Replies: 2
Reply
Join Date: Aug 2007
Posts: 98
Reputation: GLT is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
GLT GLT is offline Offline
Junior Poster in Training

auto generate id numbers

  #1  
Oct 15th, 2007
Hi guys!

I am developing a web based database for a company for my year work placement for university. As I'm still a student I am still learning so I am not 100% on what i am doing. I was wondering if someone could provide me with some help?...please!

The company wants a database that will contain all the equipment that they sell and the customers etc. The customers and equipment already have id numbers. How do I enter the Id numbers that the customers and equipment already have into the database so I dont have to provide them with new ones and still automatically generate numbers for new customers or equipment??

I was going to declare that the field auto generate all the Id numbers before I realised that the customers already have Id numbers. Can I insert my own numbers (the exsiting id's) but still declare the field to auto generate for new customers and equipment?

Any ideas would be appreciated! Thanks!!!

GLT
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,161
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Rep Power: 7
Solved Threads: 58
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: auto generate id numbers

  #2  
Oct 15th, 2007
SET IDENTITY_INSERT <tablename> ON

Place this statement before your insert statement, it allows you to enter specific id's into an identity seed column. Place this line immediately after your insert statement.

SET IDENTITY_INSERT <tablename> OFF

New id's will continue to be generated for new inserts.

I am assuming there will be a one time insert of existing customers and equipment from some other legacy system? If this is going to be a bolt on to an existing system, then you don't need to generate new id's they are already being generated so you just need a unique index.
Last edited by hollystyles : Oct 15th, 2007 at 5:20 am.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote  
Join Date: Aug 2007
Posts: 98
Reputation: GLT is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
GLT GLT is offline Offline
Junior Poster in Training

Re: auto generate id numbers

  #3  
Oct 15th, 2007
yes, ill be getting the ids from an existing system and inserting them once when i create the database for the new system.

Thank you so much!!!
ill give that a try!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MS SQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 6:12 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC