I have this stored Procedure in MS SQL2008 (C#)
ALTER PROCEDURE UpdateProducts
@ProductID INT, @Name nvarchar(50), @Length Float
AS
UPDATE Product
SET Name = @Name, Length = @Length
WHERE (ProductID = @ProductID)
Length are in some cases “” (nothing). But when “” is inserted the value 0 is inserted instead. I want the value to be null. How can I do that? This did not work:
if (Length == "")
{
Length = null;
}
Set the defaults to
NULLin the proc and you dont have to explicity passNULLto a proc.Also, if you have to send NULL from your app you would use
DBNull.Value