victorashi
IS-IT--Management
hello , thinking of normalising my db i wanted to index the name column so that there is no duplicate possible .
this is the index that i made :
ALTER TABLE [dbo].
WITH NOCHECK ADD
CONSTRAINT [PK_table] PRIMARY KEY CLUSTERED
(
[usr_id]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].
ADD
CONSTRAINT [IX_table] UNIQUE NONCLUSTERED
(
[name_of_employee]
) ON [PRIMARY]
GO
if i want to insert a new employee it runs OK , but if i want to see if it does not allow duplicates names of employee , it gives me the next errors :
Server: Msg 2627, Level 14, State 2, Procedure introducing_employee, Line 32
Violation of UNIQUE KEY constraint 'IX_table'. Cannot insert duplicate key in object 'table'.
The statement has been terminated.
Server: Msg 515, Level 16, State 2, Procedure introducing_employee, Line 53
Cannot insert the value NULL into column 'usr_id', table '1212.dbo.viza'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Server: Msg 515, Level 16, State 2, Procedure introducing_employee, Line 56
Cannot insert the value NULL into column 'usr_id', table '1212.dbo.work_permit'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Server: Msg 515, Level 16, State 2, Procedure introducing_employee, Line 59
Cannot insert the value NULL into column 'usr_id', table '1212.dbo.passport'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Stored Procedure: 1212.dbo.introducing_employee
Return Code = -6
is this normal ?
this is the index that i made :
ALTER TABLE [dbo].
CONSTRAINT [PK_table] PRIMARY KEY CLUSTERED
(
[usr_id]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].
CONSTRAINT [IX_table] UNIQUE NONCLUSTERED
(
[name_of_employee]
) ON [PRIMARY]
GO
if i want to insert a new employee it runs OK , but if i want to see if it does not allow duplicates names of employee , it gives me the next errors :
Server: Msg 2627, Level 14, State 2, Procedure introducing_employee, Line 32
Violation of UNIQUE KEY constraint 'IX_table'. Cannot insert duplicate key in object 'table'.
The statement has been terminated.
Server: Msg 515, Level 16, State 2, Procedure introducing_employee, Line 53
Cannot insert the value NULL into column 'usr_id', table '1212.dbo.viza'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Server: Msg 515, Level 16, State 2, Procedure introducing_employee, Line 56
Cannot insert the value NULL into column 'usr_id', table '1212.dbo.work_permit'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Server: Msg 515, Level 16, State 2, Procedure introducing_employee, Line 59
Cannot insert the value NULL into column 'usr_id', table '1212.dbo.passport'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Stored Procedure: 1212.dbo.introducing_employee
Return Code = -6
is this normal ?