December 12, 2003 at 6:48 am
Which is better to use?
December 12, 2003 at 8:42 am
Depends on your queries. Also - at one point, an "empty" string was not possible but always had at least one space (seems like that was a default for version 7.0 of MS-SQL).
Pros for empty strings:
- There is some benefit to always comparing <string>=<string> which is not possible if some values are potentially null.
- You don't have to "think" so hard about ordering
- In some data creation routines, it is easier to designate an empty string than a null.
Pros to NULL (my personal preference)
- Can use NULL to be mean "not yet defined" and have all other values mean something.
- Data creation routines do not need to assure that values are set.
- It seems more convenient to add null columns to an existing table.
All - in - all... it is probably up to you. I use NULL.
Guarddata-
December 12, 2003 at 10:05 am
Thanks for the info , I also wanted to know from performance and db size point of view. Which is more effecient.
December 12, 2003 at 12:58 pm
That is a rather philosophical question that doesn't have an ultimate answer. I'm inclined to say go with NULL, although NULL require some extra bytes of storage which SQL Server need to handle NULL logic properly.
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
December 15, 2003 at 2:26 am
allright, time for a different sound:
avoid NULL where possible
NULLs are giving you a hard time when comparing and with logical operators. In SQL server it even gets worse because ANSI NULLS on/off changes behavior
just my 2 dollar cent
December 15, 2003 at 2:40 am
http://www.sqlservercentral.com/forum/link.asp?TOPIC_ID=17434
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply