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 |
|
ibin
Starting Member
26 Posts |
Posted - 2009-10-14 : 08:29:08
|
| while inserting data into a datetime column for empty string it is taking the default datetime. How to avoid this and insert null |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-10-14 : 08:32:11
|
Sorry but that sounds to make no sense. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
rocknpop
Posting Yak Master
201 Posts |
Posted - 2009-10-14 : 08:34:40
|
| Check for empty string in the proc(if you have one) and insert NULLORpass "NULL" to your sql query from your appORif you have a proc do not pass the param if it is empty and make that param to accept default NULL--------------------Rock n Roll with SQL |
 |
|
|
ibin
Starting Member
26 Posts |
Posted - 2009-10-14 : 08:40:06
|
| create table temp(col1 datetime,col2 datetime)Insert into temp Values('','') now table temp would contain col11900-01-01 00:00:00.000 1900-01-01 00:00:00.000 |
 |
|
|
ibin
Starting Member
26 Posts |
Posted - 2009-10-14 : 08:40:56
|
| how to avoid the above and just leave the col1 and col2 to be empty. Hope i make sense now........ |
 |
|
|
ibin
Starting Member
26 Posts |
Posted - 2009-10-14 : 08:44:06
|
well thanks... how stupid i am... |
 |
|
|
rocknpop
Posting Yak Master
201 Posts |
Posted - 2009-10-14 : 08:44:10
|
| DECLARE @T TABLE(ID INT IDENTITY(1,1),COL1 DATETIME,COL2 DATETIME)INSERT INTO @T VALUES (NULL,NULL)SELECT * FROM @TWhy cannot you simply insert NULL. Are you talking about a parameter which is empty?--------------------Rock n Roll with SQL |
 |
|
|
|
|
|