Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 9th, 2003, 08:13 AM
Yovav Yovav is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Holy Land
Posts: 18 Yovav User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 11 sec
Reputation Power: 0
Send a message via ICQ to Yovav
When should I use IDENTITY field ?

Hi all.

I'm going to create a big DB that will hold important info
(the usual stuff - Clients, Products, Orders...)

I wonder where should I use the IDENTITY field,
for example - on Orders I will have Order_ID...
(and where does SQL server the numbers of a deleted records)


My fear is that IDENTITY fields will go wrong somehow so I can
loose connections within the tables
(maybe when restoring my DB to some other locations... with DTS... or other issues)


1. When should I use IDENTITY field ?

2. If I do NOT - how can I lock a record when I add a new one




P.S.

How can I alter a table turning ON or OFF an IDENTITY field ?

for example:
if I had my DB with Client_ID as an I IDENTITY field and for some reason it has
changed to just INT (with no IDENTITY) - how can I tell it to be IDENTITY field again ?

Reply With Quote
  #2  
Old November 9th, 2003, 09:47 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 29 m 58 sec
Reputation Power: 181
There are lots of debates on this subject, some sql designers think identity values are close to heresy, others use identity all the time.

I generally use an identity column as a primary key value in most tables myself.

If you need numbers without any gaps, don't use identity. And converting out & back to identity might mess up your keys.

Reply With Quote
  #3  
Old November 9th, 2003, 10:03 PM
Yovav Yovav is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Holy Land
Posts: 18 Yovav User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 11 sec
Reputation Power: 0
Send a message via ICQ to Yovav
Thanks,

What I don't seems to understand is how SQL Server knows
which unique numbers already been used
(does it write this info in some table ??)

+

if I'm going to use IDENTITY fields for some tables,
how can I also use the old fashion (safer option) on SQL Server ?
should I "lock" a record before I write ? (how ?)

Do U have a suggestion for me or a link to an article about this ?

Last edited by Yovav : November 9th, 2003 at 10:06 PM.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > When should I use IDENTITY field ?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT