Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
error:

SQL
Violation of UNIQUE KEY constraint 'UQ__Resource__3552E9B6'. Cannot insert duplicate key in object 'dbo.Resource'.
The statement has been terminated.



USE [Resource Management]
GO
/****** Object:  Table [dbo].[Resource]    Script Date: 04/03/2013 18:15:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Resource](
	[OrganisationID] [int] NOT NULL,
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[FirstName] [nvarchar](50) NOT NULL,
	[LastName] [nvarchar](50) NULL,
	[MiddleName] [nvarchar](50) NULL,
	[Password] [nvarchar](50) NULL,
	[PrimarySkill] [nvarchar](50) NULL,
	[SecondarySkill] [nvarchar](50) NULL,
	[Role] [nvarchar](50) NULL,
	[JobTitle] [nvarchar](50) NULL,
	[PrimaryEmail] [nvarchar](50) NOT NULL,
	[ClientEmail] [nvarchar](50) NULL,
	[Address] [nvarchar](max) NULL,
	[JobType] [nvarchar](50) NULL,
	[VisaStatus] [nvarchar](50) NULL,
	[PersonalEmail] [nvarchar](50) NOT NULL,
	[PrimaryPhone] [varchar](50) NULL,
	[SecondaryPhone] [varchar](50) NULL,
	[ResourceManager] [nvarchar](50) NULL,
	[Customer] [nvarchar](50) NULL,
	[StartDate] [datetime] NULL,
	[TaxTerms] [nvarchar](50) NOT NULL,
	[Reference1] [nvarchar](50) NULL,
	[Reference2] [nvarchar](50) NULL,
	[C2CEmployerName] [nvarchar](50) NULL,
	[C2CEmployerAddress] [nvarchar](50) NULL,
	[C2CEmployerTaxID] [nvarchar](50) NULL,
	[C2CPhone] [varchar](50) NULL,
	[C2CModeOfPayment] [nvarchar](50) NULL,
	[C2CFaxNo] [nvarchar](50) NULL,
	[C2CBankDetails] [nvarchar](50) NULL,
	[BillRate] [varchar](50) NULL,
	[PayRate] [varchar](50) NULL,
	[WorkType] [nvarchar](50) NULL,
	[EndDate] [datetime] NULL,
	[SSN] [nvarchar](50) NULL,
	[ModeOfPayment] [nvarchar](50) NULL,
	[BankDetails] [nvarchar](50) NULL,
	[W2ContractorPerDiem] [nvarchar](50) NULL,
	[W2Amount] [nvarchar](50) NULL,
	[Status] [int] NULL CONSTRAINT [DF_Resource_Status]  DEFAULT ((1)),
 CONSTRAINT [PK_Resource] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [UQ__Resource__3552E9B6] UNIQUE NONCLUSTERED 
(
	[ClientEmail] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[Resource]  WITH CHECK ADD  CONSTRAINT [FK__Resource__Organi__24285DB4] FOREIGN KEY([OrganisationID])
REFERENCES [dbo].[Organisation] ([OrganisationID])
GO
ALTER TABLE [dbo].[Resource] CHECK CONSTRAINT [FK__Resource__Organi__24285DB4]
Posted
Comments
ZurdoDev 3-Apr-13 8:54am    
The error tells you the problem. What is the question?
Pheonyx 3-Apr-13 8:59am    
Did this table already exist at some point and you have removed it to test the script?

The error message is related to the UNIQUE constraint and not to the primary key.

Can you please write insert statement you are using or try inserting any value to the column which you have marked unique.
 
Share this answer
 
Comments
Dhritirao's 4-Apr-13 7:51am    
yes i have cleared that one now working fine
We could do with seeing what SQL you are executing but I have a feeling that you are trying to enter data that has the same client email that is already in the table.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900