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.
| Author |
Topic |
|
barnabeck
Posting Yak Master
236 Posts |
Posted - 2010-07-08 : 07:09:27
|
| I'm setting up a form that updates calendar entries. There are 4 columns for each day. I want these columns to be updated, but just in case that a value had been inserted in the form for that column. If 2 out of 4 values have been filled in, these two columns should be updated, while the other columns keep their original values.Working with the original_values and the OldValuesParameterFormatString="original_{0}" control just seems to work for a single record, while I need to update these values for a period of time defined by controlparameter @StartDay and @EndDay.UPDATE [PERSONAL] SET [horas_pres] = CASE WHEN @horas_pres IS NULL THEN @original_horas_pres ELSE @horas_pres END WHERE (dia >= @StartDay and dia <= @EndDay)Any suggestions,Martin |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-07-08 : 07:14:30
|
| [code]UPDATE [PERSONAL] SET [horas_pres] = COALESCE(@horas_pres, [horas_pres])WHERE (dia >= @StartDay and dia <= @EndDay)[/code]or if @horas_pres might be an empty string (which you don't want to use) then[code]UPDATE [PERSONAL] SET [horas_pres] = COALESCE(NullIf(RTrim(@horas_pres), ''), [horas_pres])WHERE (dia >= @StartDay and dia <= @EndDay)[/code] |
 |
|
|
barnabeck
Posting Yak Master
236 Posts |
Posted - 2010-07-09 : 03:23:45
|
| That is fantastic! Thank you!Martin |
 |
|
|
|
|
|