Help with generating a unique number

Thread Solved

Join Date: Aug 2009
Posts: 9
Reputation: kevlam is an unknown quantity at this point 
Solved Threads: 0
kevlam kevlam is offline Offline
Newbie Poster

Help with generating a unique number

 
0
  #1
Oct 7th, 2009
hello,

I'm trying to create a database in SQL Server management Studio for a project. I have created a tabel named Employee and I have 14 columns. I need to set the firts column (Emp_ID) as Primary Key (accomplished) and then generate a unique number for each Emp_ID that I insert. currently I have no information in my database I'm stuck in finding the procedure to correctly code the SQL statement that will generate a unique Emp_ID when I insert new values or add a new row of information. Can someone please help? I"ve look all over my text and searched the web and cannot find something useful to help.

thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,392
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 168
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso
 
0
  #2
Oct 8th, 2009
  1. CREATE TABLE Employee
  2. (
  3. Emp_Id INT PRIMARY KEY IDENTITY,
  4. LastName VARCHAR(255) NOT NULL,
  5. FirstName VARCHAR(255),
  6. Address VARCHAR(255),
  7. City VARCHAR(255),
  8. postalcode vachar(6),
  9. /* other columns*/
  10. )
not sure about sql server, identity SHOULD be the keyword to make it autoincrement
Last edited by almostbob; Oct 8th, 2009 at 12:35 am.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 9
Reputation: kevlam is an unknown quantity at this point 
Solved Threads: 0
kevlam kevlam is offline Offline
Newbie Poster
 
0
  #3
Oct 8th, 2009
Thank you very much for your help
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 394 | Replies: 2
Thread Tools Search this Thread



Tag cloud for MySQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC