Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Buceador
Starting Member
2 Posts |
Posted - 2008-01-29 : 14:44:36
|
Hello,I am creating a new table for the historical data of the employees on my company.On the table I get Fromdate, Todate, EmployeeID, .... etcI want to make the Primary Key the fields Fromdate, EmployeeID that the combination have to be unique.I make the primary key with the following code lines:ALTER TABLE dbo.tblRES_Employee_HISTORICAL ADD CONSTRAINT PK_Test2Columns PRIMARY KEY (FromDate, EmployeeID) I am trying to bulk insert 276 rows on the table I get the following error:Server: Msg 2627, Level 14, State 1, Line 1Violation of PRIMARY KEY constraint 'PK_Test2Columns'. Cannot insert duplicate key in object 'tblRES_Employee_HISTORICAL'.The statement has been terminated. When I insert the first row alone it work fine, but when I try to get a second row give me the same error.Please can anybody help me.Thank you in advance and regards.Javier. |
|
Buceador
Starting Member
2 Posts |
Posted - 2008-01-29 : 14:49:56
|
Sorry, I figure out that I have the EmployeeID and the StationID field in a bad order and the StationID is a field that could be repeated.Thank and regards. |
 |
|
|
|
|