MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Simple Question - Does SQL Server 2005 Allows NULL for DateT

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> C Sharp
Author Message
jehugaleahsa



Joined: 19 Oct 2007
Posts: 12

PostPosted: Tue Feb 26, 2008 12:38 pm    Post subject: Simple Question - Does SQL Server 2005 Allows NULL for DateT Reply with quote

Does SQL Server 2005 Allows NULL for DateTime? Just checking.

Archived from group: microsoft>public>dotnet>languages>csharp
Back to top
View user's profile Send private message
Lasse_Vågsæther_Karlsen



Joined: 08 Aug 2007
Posts: 12

PostPosted: Tue Feb 26, 2008 9:44 pm    Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D Reply with quote

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
View user's profile Send private message
Alberto Poblacion



Joined: 08 Aug 2007
Posts: 2

PostPosted: Tue Feb 26, 2008 9:46 pm    Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D Reply with quote

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
View user's profile Send private message
Jon Skeet [C# MVP]



Joined: 08 Aug 2007
Posts: 266

PostPosted: Tue Feb 26, 2008 8:46 pm    Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D Reply with quote

jehugaleahsa@gmail.com wrote:
> Does SQL Server 2005 Allows NULL for DateTime? Just checking.

Yes, so long as your column is nullable.

--
Jon Skeet -
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Back to top
View user's profile Send private message
Jon Skeet [C# MVP]



Joined: 08 Aug 2007
Posts: 27

PostPosted: Tue Feb 26, 2008 12:53 pm    Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D Reply with quote

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
View user's profile Send private message
jehugaleahsa



Joined: 19 Oct 2007
Posts: 12

PostPosted: Tue Feb 26, 2008 1:16 pm    Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D Reply with quote

On Feb 26, 8:38 am, "jehugalea...@gmail.com"
wrote:
> Does SQL Server 2005 Allows NULL for DateTime? Just checking.

Thanks.
Back to top
View user's profile Send private message
"Cowboy \



Joined: 08 Aug 2007
Posts: 60

PostPosted: Tue Feb 26, 2008 3:53 pm    Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D Reply with quote

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
View user's profile Send private message
Arne_Vajhøj



Joined: 08 Aug 2007
Posts: 39

PostPosted: Wed Feb 27, 2008 1:29 am    Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D Reply with quote

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
View user's profile Send private message
Paul E Collins



Joined: 08 Aug 2007
Posts: 3

PostPosted: Wed Feb 27, 2008 3:47 pm    Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D Reply with quote

"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
View user's profile Send private message
Jon Skeet [C# MVP]



Joined: 08 Aug 2007
Posts: 27

PostPosted: Wed Feb 27, 2008 8:10 am    Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D Reply with quote

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
View user's profile Send private message
Paul E Collins



Joined: 08 Aug 2007
Posts: 3

PostPosted: Wed Feb 27, 2008 10:55 pm    Post subject: Re: Simple Question - Does SQL Server 2005 Allows NULL for D Reply with quote

"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
View user's profile Send private message
Display posts from previous:   
Related Topics:
Simple question Why is dotnet called so? I mean, several peoples mix dotnet development with domain names ... And several peoples also think that with dotnet framework, you can only develop internet based Where do this came from? An

Simple Question Hi, I am writing a graphing application that needs to have multiple instances of custom graphs written vertically. I then need a governer that can interact with all the graphs by drawing a vertical line to line up the graph points. My basic question is I

Newbe Question: How to get a simple class to display in Auto Hi, sorry if this is off group but I'm new to this and don't know where to start. I've designed several classes and I want them to display succinctly in the window. For example I have a point class and I would like it to show up like Poin

SQL Server 2005 compact edition with VB OK so I've downloaded and installed this 1.7MB wonder, but now what? I just wanted a nice easy to deploy db to use with my VB 6 app and although the size is now great it doesn't seem to be doing much else. Nothing in the start menu, sys tray, desktop, etc

Error Importing CVS into SQL Server 2005 using SQLBulkCopy a Hi, I'm using SQLBulkCopy via c#, I'm importing a large text file into a destination SQL Table, the file contains multiple columns and is about 100k records, I am getting the following error: 'Could not allocate space for object
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> C Sharp All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group