Hi,
I am facing two problem while working with Default constraint.
My table "shippers" includes 3 columns: "Shippers ID(identity colmn) ",
"shippersName","ShippedDate", like this:
Shippers ID (identity)
ShippersName Default = 'ashok' NOT NULL
ShippedDate Default = GetDate() NOT NULL
Now I have provided default constraints on "Shippersname" with Default value ashok and for "shippeddate" as getdate() Note that all the column are not null
This constraints is working fine when I am using a query like:
insert into shippers (shippersName) values ('nishu')
or
insert into shippers (shippeddate) values ('01/01/2008')
In first case since I have not provided shippeddate so it is taking my defualt value getdate() and in second I
have not provided shippersName so it is taking my default value <ashok>
My problem is when I am using a query like
insert into shippers (shippersName, shippeddate) values ('','')
Then in above case also I am not providing any value so it should dake my default value but
what is happening is shippeddate is taking default value of SQL server 1900-01-01 00:00:00.000 and
shippersName is blank. It is not even NULL I want to ask 2 questions
- When I am using '' for varchar. Is it working as some value? Isn't equal to null
- Why when I am using '' as for dattime it is not taking my default date and rather taking SQL default date