Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi,This may be a bit of a stupid question - I've been away from SQL for a couple of years now.But...What's the best way to create a stored procedure that updates a row (given an ID), and also updates any or all of the columns based on the parameters passed to it?e.g. The same sp might be used to update just one column in a row, or all of them.Thanks
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2007-12-13 : 11:02:09
something like this
update tset cola = coalesce(@cola, cola), colb = coalesce(@colb, colb), . . . from yourtable twhere id = @ID