Knowledgebase
TimeTrack support > TimeTrack support > Knowledgebase

Search help:


Primary Key

Solution

Add primary key to an existing table

  • If for any reason, the primary key is removed from the table, executing a query will add the primary key to the table.

ALTER TABLE tbl_trans_Attendance20 ADD CONSTRAINT PKAttendance20 PRIMARY KEY (EmployeeCode,PunchDate)

 

  • Ensure that the columns are NOT NULL before executing the query.

  • If its NULL, first execute the following queries to make it NOT NULL


ALTER TABLE   tbl_trans_Attendance20 ALTER COLUMN  EmployeeCode NVARCHAR(20) NOT NULL

ALTER TABLE   tbl_trans_Attendance20 ALTER COLUMN  PunchDate [smalldatetime] NOT NULL

 

This is a sample for tbl_trans_Attendance20. Remember to modify this and PKAttendance20 as per the year for which the primary key need to be added

 

 

 
Was this article helpful? yes / no
Related articles Software Slow
Payroll Import - User Table Import - Basic Import
SQL Query Planner
SQL Log File
Article details
Article ID: 69
Category: TimeTrack General
Date added: 25/02/2021 10:29:24
Views: 154
Rating (Votes): Article rated 5.0/5.0 (1)

 
« Go back