I am having some difficulty with SQL Server where I am creating a table called
INSERT INTO EMPLOYEE
The INSERT statement conflicted with the CHECK constraint "chk_DATEJOINED". The conflict occurred table "dbo.EMPLOYEE", column 'dateJoined'.
CREATE TABLE EMPLOYEE
employeeNum int NOT NULL IDENTITY(1,1),
name varchar(40) NOT NULL,
dateJoined date NOT NULL DEFAULT GETDATE()
CHECK (dateJoined >= CAST('01-dec-2010' as DATETIME))
This can be done in several ways.
1) like everyone else has pointed out. State which columns you want to populate and skipping the dateJoined column.
insert into Employee ( name ) values ( 'John' )
2) Use the default keyword as the value.
insert into Employee ( name, dateJoined ) values ( 'John', default )
The default keyword is useful if you're building an SQL statement in code and want the column list explicitly set. Default keyword defaults to null if there isn't a default constraint on the column so watch out for columns declared as not null.