.NET: Allow NULLS in DB fields?

I have the task of refactoring SQLServer DB .... Many tables and "ALLOW NULLS" columns, this is good practice ...

It seems I remember authour from CSLA.NET saying that it was really bad practice to allow zeros in DB ...

If so, what are my alternatives?

Remove all "ALLOW NULLS" from all columns .... and in the numeric columns use a value of -1, for example,

I would really appreciate any input anyone has.

I am currently using a model (from an entity framework) from my database and db columns that "ALLOW NULLS" are zeros ... and some of the stored procedures require me to have a default value ... i.e. BOOLEAN requires FALSE by default ... but this value is null.

Well, I do not want to deviate from my original question, ALLOW NULLS is a bad thing from what I can collect .... so how can I fix this?

Any help really appreciated

+5
source share
4 answers

There is no doubt that NULL should be avoided whenever possible, due to problems that may occur when several problems arise with indexing and query syntax.

- , NULL, , . , , - , , , NULL . , , .

- . NULL , , - .

, , " ", , , - . , , , , - (-1? ) , , -. Oye.

- . " ", .NET, DateTime , DateTime.MinValue , , 1 0001 . SQL, DATETIME SQL Server - 1 1973 . -, , , , , , SqlDateTime.MinValue, , DateTime.MinValue. Double Oye.

, , , , . , ( ​​). , , , , NULL, . , , , , ; . , , , , , , , .

+8

Null , , .

, , :

update TableA set ColumnA = 'default value' where ColumnA is null 

... " null" .

, null , .

+1

- , . NULL , . (BIT) .

. .

, . Nullable generic .net framework .

+1

NULL - , - . , , ( SQL) . , SQL .

, , - NULL , , .

-4

All Articles