SQL Server Zero Column

I have a SQL Server table with multiple varchar columns that are NULL. When an aspx page sends data, if the text field is empty, the database table column is updated to an empty row.

To preserve a null value, instead of replacing it with an empty string, I can either logically change the empty string to System.DBnull in mid-level C # code, or do this in a stored procedure.

Are there any better ways to handle this situation?

+3
source share
2 answers

you can use a trigger or do it in proc, you can use a function NULLIF

Example

DECLARE @d VARCHAR(20)
SELECT @d = ''
SELECT NULLIF(@d,'')
+4
source

, , , , . , .

0

All Articles