Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Table
SQL
Create Table #Temp(CrtDt Datetime)

and i want to insert some blank value into that table i am trying like this
SQL
insert into #Temp values('')


But i am getting data in into my Table

CrtDt
1900-01-01 00:00:00

Can any one Help me to insert blank data in my table if it is possible.
Posted
Comments
Richard C Bishop 9-Apr-13 11:38am    
Try inserting "NULL".

Change your table definition to be clearer:
SQL
Collapse | Copy Code
Create Table #Temp(CrtDt Datetime NULL)
(It defaults to a nullable field but it's a little more obvious) then just insert a null value:
SQL
INSERT INTO #Temp (CrtDt) VALUES(null)
 
Share this answer
 
Comments
[no name] 9-Apr-13 11:52am    
Due to some validation Region i do not null values i want either correct Datetime value or blank value
Maciej Los 9-Apr-13 11:59am    
You can always treat 1900-01-01 00:00:00 as a blank value ;)
OriginalGriff 9-Apr-13 12:13pm    
Your choices are simple: null or a valid dateTime. Personally, I would use a null, or the minimum dtaatime value (with for s DATETIME column is 1753-01-01 @ 00:00:00.000, for a DATETIME2 it is 0001-01-01 @ 00:00:00.000.
If you supply a blank or zero value, there is an implicit cast to Jan 1st 1900, which means it is probably a bad value to use.

I would use a null if I meant "this field has no value set".
Maciej Los 9-Apr-13 11:58am    
+5
[no name] 9-Apr-13 12:03pm    
That mean i can not insert blank value in column which data type is DateTine
Additional information about DateTime datatype you can find here: http://technet.microsoft.com/en-us/library/ms187819.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900