I have a stored procedure for sql server 2008 like this:
create procedure test_proc
@someval int,
@id int
as
update some_table
set some_column = ISNULL(@someval, some_column)
where id = @id
go
If the parameter @someval is NULL, this SP will just use the existing value in some_column.
Now I want to change this behaviour such that if value for @someval is 0, a NULL is stored in some_column otherwise it behave just the way it is doing now.
So I am looking for something like:
if @someval == 0
set some_column = NULL
else
set some_column = ISNULL(@someval, some_column)
I don't have the option to create a varchar @sql variable and call sq_executesql on it (at least that is the last thing I want to do). Any suggestions on how to go about doing this?