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 |
|
sital
Yak Posting Veteran
89 Posts |
Posted - 2009-06-17 : 03:32:21
|
| HiI have created the following table and I have assigned a default constraint to the column DateOfJoining but When I insert the values the default values is not inserted. The following is the statement used for creating Table and Default constraint:create table NewUserRegister(UserName nvarchar(50) constraint pk_UserName primary key,Password nvarchar(30) not null)alter table NewUserRegister add constraint df_DateOfJoining default getdate() for DateOfJoiningBoth the above statement are working fine without any error.But while inserting the default values is not inserted.Can any one help me out in finding the problem with the default constraint?Please tell me how to rectify the above mistake?Please Reply soon it is urgent |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-17 : 03:41:34
|
I get this error, because the DateofJoining Column is not present in the tableMsg 1752, Level 16, State 0, Line 2Column 'DateOfJoining' in table 'NewUserRegister' is invalid for creating a default constraint. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-17 : 03:43:28
|
This workscreate table NewUserRegister(UserName nvarchar(50) constraint pk_UserName primary key,Password nvarchar(30) not null,DateOfJoining DATETIME)alter table NewUserRegister add constraint df_DateOfJoining default getdate() for DateOfJoining E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|