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 |
|
raju2647
Starting Member
22 Posts |
Posted - 2004-10-28 : 12:10:41
|
| Hello,. I'm running an insert query and one of the fields is date/time.When I DO NOT send a value to it, I want to insert is as <NULL>, but instead, it's going in as "1/1/1900".How should I do my query where I can send a NULL Value?Thanks,raju |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-10-28 : 12:23:48
|
are u inserting it from .net?you need to put the date field to DBNull.Valuein sql:insert into table1(dateCol, id)select null, 1Go with the flow & have fun! Else fight the flow |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2004-10-28 : 12:26:22
|
| insert table( fld1, datefield)values( 'xxx', null)There is probably a default on the column (0),or if it is a client app that inserts the data using a scalar datatype then the client probably sets the value to 0 instead of a null value.rockmoose |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2004-10-28 : 12:26:57
|
rockmoose |
 |
|
|
raju2647
Starting Member
22 Posts |
Posted - 2004-10-28 : 12:28:50
|
| haishould i give the value as DBNull.Value in the sql stmt in .NET.pls explain the queryraju |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-10-28 : 12:31:52
|
well it would be best if you show us how you build your query.Go with the flow & have fun! Else fight the flow |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-10-28 : 22:33:23
|
quote: Originally posted by raju2647 Hello,. I'm running an insert query and one of the fields is date/time.When I DO NOT send a value to it, I want to insert is as <NULL>, but instead, it's going in as "1/1/1900".How should I do my query where I can send a NULL Value?Thanks,raju
in your table, allow the column to accept null values,in your .net app, don't pass anything if value is null--------------------keeping it simple... |
 |
|
|
|
|
|
|
|