Board index » delphi » Unique record guarantee?
Naser Fadaei
![]() Delphi Developer |
Naser Fadaei
![]() Delphi Developer |
Unique record guarantee?2006-03-07 02:03:55 PM delphi42 Hi, if I insert a record to a table in sqlserver2000, the record is added even if the same record aready exists (without any error)! in MS Access there is AutoNumber type that increaments for every incoming new record; so there are no 2 records identical. what is solution for sqlserver2000? |
Oliver Townshend
![]() Delphi Developer |
2006-03-07 02:18:27 PM
Re:Unique record guarantee?QuoteHi, if I insert a record to a table in sqlserver2000, the record is added Oliver Townshend |
Martijn Tonies
![]() Delphi Developer |
2006-03-07 04:44:09 PM
Re:Unique record guarantee?QuoteHi, if I insert a record to a table in sqlserver2000, the record is added Quotein MS Access there is AutoNumber type that increaments for every incoming Martijn Tonies Database Workbench - development tool for MS SQL, and more! Upscene Productions www.upscene.com My thoughts: blog.upscene.com/martijn/ Database development questions? Check the forum! www.databasedevelopmentforum.com |
Nirav Patel
![]() Delphi Developer |
2006-03-08 04:26:01 AM
Re:Unique record guarantee?
Use IDENTITY
Example IF NOT EXISTS(SELECT [name] FROM sysobjects WHERE [name] = 'tblAttachment' AND [xtype] = 'U') BEGIN CREATE TABLE [tblAttachment] ( AttachmentID INTEGER IDENTITY(1, 1) NOT NULL, AttachmentName VARCHAR(255) NOT NULL, Attachment IMAGE ) END; DON'T USE GUID as a column type unless you absolutely absolutely need them. They tend to kill the performance. Besides IDENTTY makes sure that the number always stays UNIQUE. "Oliver Townshend" <oliveratzipdotcomdotau>writes Quote>Hi, if I insert a record to a table in sqlserver2000, the record is |
Oliver Townshend
![]() Delphi Developer |
2006-03-08 06:24:17 AM
Re:Unique record guarantee?QuoteDON'T USE GUID as a column type unless you absolutely absolutely need latter, but it does come up. Oliver Townshend |
Martijn Tonies
![]() Delphi Developer |
2006-03-08 06:48:29 AM
Re:Unique record guarantee?Quote>DON'T USE GUID as a column type unless you absolutely absolutely need A constraint will make sure it stays unique. As the original poster said: when inserting the same record -> so that could include a primary key value, when not enforced. -- Martijn Tonies Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL Server Upscene Productions www.upscene.com My thoughts: blog.upscene.com/martijn/ Database development questions? Check the forum! www.databasedevelopmentforum.com |
Naser Fadaei
![]() Delphi Developer |
2006-03-08 12:26:10 PM
Re:Unique record guarantee?
Thanks to all friends!
"Naser Fadaei" <XXXX@XXXXX.COM>writes QuoteHi, if I insert a record to a table in sqlserver2000, the record is added |
Arthur Hoornweg
![]() Delphi Developer |
2006-03-20 05:11:38 PM
Re:Unique record guarantee?
Oliver Townshend writes:
QuoteGUID gets merged at our office into one single database. This is only possible with GUID primary keys. In my experience GUID performance is not a problem at all. I think it is a myth. A guid is internally stored as a 16-byte number if I am not mistaking, so two guids can be compared by SQL server by simply performing 4 DWORD compares. I wouldn't be surprised if a GUID primary key is faster than a varchar primary key. -- Arthur Hoornweg (In order to reply per e-mail, please just remove the ".net" from my e-mail address. Leave the rest of the address intact including the "antispam" part. I had to take this measure to counteract unsollicited mail.) |