Jay said:
For a column that contains a string (let's say varchar[50]), is there any
performance advantage in not allowing nulls, and using an empty string
("")
to instead?
For perfomance, I have no idea. Probably none.
But I must confess I've done a not null on a varchar
- just to make sure I always get a string and not a null from the database.
I work a lot with ASP.NET and sporting a string as a null,
is a no no. It makes your whole webpage goes kaboom.
Enforcing rules on a database just to have your C# easier
is wrong in my opinion. But very safe in .NET 1.1
For .NET 2.0 and above, it is just stupid as you can always do:
string s = MyData[col, row].SomeValue ?? "";
....
As a sidenote, remember the thread on "" and String.Empty?
Here is a good example why "" is sometimes better...
1) string s = MyData[col, row].SomeValue ?? "";
2) string s = MyData[col, row].SomeValue ?? String.Empty;
1) readable, we want SomeValue
2) too verbose, if you read it fast, you might be looking for SomeEmpty
below. *s*
- Michael Starberg