|
| Author |
Message |
jehugaleahsa
Joined: 19 Oct 2007 Posts: 12
|
Posted: Tue Feb 26, 2008 12:38 pm Post subject: Simple Question - Does SQL Server 2005 Allows NULL for DateT |
|
|
Does SQL Server 2005 Allows NULL for DateTime? Just checking.
Archived from group: microsoft>public>dotnet>languages>csharp |
|
| Back to top |
|
 |
Lasse_Vågsæther_Karlsen
Joined: 08 Aug 2007 Posts: 12
|
Posted: Tue Feb 26, 2008 9:44 pm Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D |
|
|
jehugaleahsa@gmail.com wrote:
> Does SQL Server 2005 Allows NULL for DateTime? Just checking.
SQL Server 2005 allows NULL for any data type to my knowledge, you flag
this as an additional option on the column, wether to allow NULL or not.
--
Lasse Vågsæther Karlsen
mailto:lasse@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3 |
|
| Back to top |
|
 |
Alberto Poblacion
Joined: 08 Aug 2007 Posts: 2
|
Posted: Tue Feb 26, 2008 9:46 pm Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D |
|
|
wrote in message @z17g2000hsg.googlegroups.com...
> Does SQL Server 2005 Allows NULL for DateTime? Just checking.
Yes, SQL Server alows it. On the other hand, .Net does not (DateTime in
..Net is a Value Type) so be careful when designing your client code to
receive the DateTime values returned from Sql Server. |
|
| Back to top |
|
 |
Jon Skeet [C# MVP]
Joined: 08 Aug 2007 Posts: 266
|
|
| Back to top |
|
 |
Jon Skeet [C# MVP]
Joined: 08 Aug 2007 Posts: 27
|
Posted: Tue Feb 26, 2008 12:53 pm Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D |
|
|
On Feb 26, 3:46 pm, "Alberto Poblacion"
email_removed wrote:
> > Does SQL Server 2005 Allows NULL for DateTime? Just checking.
>
> Yes, SQL Server alows it. On the other hand, .Net does not (DateTime in
> .Net is a Value Type) so be careful when designing your client code to
> receive the DateTime values returned from Sql Server.
Well, so long as you're not using .NET 1.1 there's the fairly obvious
choice of Nullable (aka "DateTime?").
Jon |
|
| Back to top |
|
 |
jehugaleahsa
Joined: 19 Oct 2007 Posts: 12
|
Posted: Tue Feb 26, 2008 1:16 pm Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D |
|
|
On Feb 26, 8:38 am, "jehugalea...@gmail.com"
wrote:
> Does SQL Server 2005 Allows NULL for DateTime? Just checking.
Thanks. |
|
| Back to top |
|
 |
"Cowboy \
Joined: 08 Aug 2007 Posts: 60
|
Posted: Tue Feb 26, 2008 3:53 pm Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D |
|
|
If the database table is set up that way? Yes.
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
*************************************************
| Think outside the box!
|
*************************************************
wrote in message @z17g2000hsg.googlegroups.com...
> Does SQL Server 2005 Allows NULL for DateTime? Just checking. |
|
| Back to top |
|
 |
Arne_Vajhøj
Joined: 08 Aug 2007 Posts: 39
|
Posted: Wed Feb 27, 2008 1:29 am Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D |
|
|
jehugaleahsa@gmail.com wrote:
> Does SQL Server 2005 Allows NULL for DateTime? Just checking.
I am pretty sure that all relational databases by definition has to
support NULL for all data types.
Arne |
|
| Back to top |
|
 |
Paul E Collins
Joined: 08 Aug 2007 Posts: 3
|
Posted: Wed Feb 27, 2008 3:47 pm Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D |
|
|
"Jon Skeet [C# MVP]" wrote:
> Well, so long as you're not using .NET 1.1 there's the fairly obvious
> choice of Nullable (aka "DateTime?").
SqlDateTime is a bit safer because its MinValue and MaxValue match those
of SQL Server.
Eq. |
|
| Back to top |
|
 |
Jon Skeet [C# MVP]
Joined: 08 Aug 2007 Posts: 27
|
Posted: Wed Feb 27, 2008 8:10 am Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D |
|
|
On Feb 27, 10:47 am, "Paul E Collins"
wrote:
> > Well, so long as you're not using .NET 1.1 there's the fairly obvious
> > choice of Nullable (aka "DateTime?").
>
> SqlDateTime is a bit safer because its MinValue and MaxValue match those
> of SQL Server.
On the other hand, that leaks the database nature of it into the rest
of the code. I prefer to have my entity code non-database-specific.
I also tend to avoid using MinValue and MaxValue in the first place,
as they're rarely useful values. Point taken that it's nice to have
them aligned on occasion though.
Jon |
|
| Back to top |
|
 |
Paul E Collins
Joined: 08 Aug 2007 Posts: 3
|
Posted: Wed Feb 27, 2008 10:55 pm Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D |
|
|
"Jon Skeet [C# MVP]" wrote:
> I also tend to avoid using MinValue and MaxValue in the first place,
> as they're rarely useful values.
Yes, I suppose I only ever used MinValue as a "no date" flag before C#
had nullable structs.
Eq.
|
|
| Back to top |
|
 |
|