Go Back   iTrader Forums » iTrader Chat » General Chit Chat » Databases MySQL| PostgreSQL| Oracle| SQL Server

Databases MySQL| PostgreSQL| Oracle| SQL Server Discuss database related issues.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 13th August 2008, 11:31 AM
Junior Member
 
Join Date: Aug 2008
Posts: 1
Credits: 0
Default Prevent Duplicate Records on an MS SQL Database Column?

How to prevent duplicate values in an SQL Management Studio Express column. I have a table where the Primary Key is the CountryID, then I have a CountryName column which I would like to prevent duplicate entries from occurring. Please indicate how to set this column property so it would not allow duplicates.Thanks!Manuel
Reply With Quote
  #2 (permalink)  
Old 13th August 2008, 12:30 PM
Junior Member
 
Join Date: Aug 2008
Posts: 1
Credits: 0
Default

Java tutorials-http://java-tip.org/
Reply With Quote
  #3 (permalink)  
Old 13th August 2008, 12:40 PM
Junior Member
 
Join Date: Aug 2008
Posts: 1
Credits: 0
Default

Create an Index on the Country Name column specifying in the properties of the Index that it is Unique Is Unique = TrueThis should prevent duplicate Country names.Script FollowsUSE [MyDemo_DB]GO/****** Object: Table [dbo].[Country_TBL] Script Date: 08/13/2008 00:30:40 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE [dbo].[Country_TBL]([CountryID] [int] NOT NULL,[Country Name] [nchar](10) NOT NULL, CONSTRAINT [PK_Country_TBL] PRIMARY KEY CLUSTERED ([CountryID] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]USE [MyDemo_DB]GO/****** Object: Index [IX_Country_TBL] Script Date: 08/13/2008 00:33:25 ******/CREATE UNIQUE NONCLUSTERED INDEX [IX_Country_TBL] ON [dbo].[Country_TBL] ([Country Name] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
Reply With Quote
  #4 (permalink)  
Old 13th August 2008, 01:19 PM
Junior Member
 
Join Date: Aug 2008
Posts: 1
Credits: 0
Default

graphics design-http://userstyle.org/
Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:25 PM. Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
Ad Management by RedTyger


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72