ByzantianX
Programmer
- Dec 18, 2000
- 103
I need to make a stored procedure on sql server which should look like this:
create sp1
@prm1 text, @prm2 int, @prm3 bit.... @prmN (any data type)
as
set no count on
update tbl
set fld1=@prm1
fld2=@prm2
.
.
.
fldN=@prmN
return
but the trick is that I need those parameters to be optional. So, if I pass some value to the parameter that the procedure do not update that particular field.Is there any elegant solution which exclude loop etc.?
Thank you in advance!
create sp1
@prm1 text, @prm2 int, @prm3 bit.... @prmN (any data type)
as
set no count on
update tbl
set fld1=@prm1
fld2=@prm2
.
.
.
fldN=@prmN
return
but the trick is that I need those parameters to be optional. So, if I pass some value to the parameter that the procedure do not update that particular field.Is there any elegant solution which exclude loop etc.?
Thank you in advance!