| Databases MySQL| PostgreSQL| Oracle| SQL Server Discuss database related issues. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
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
|
|
|||
|
|
|
|||
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]
|
|
|||
|
|
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
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
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





Linear Mode
