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 |
|
lappin
Posting Yak Master
182 Posts |
Posted - 2011-04-12 : 10:49:53
|
| Hi, I've recently modified a column to be a calculated column. Is it possible to set sql server to ignore attempts to update this field rather than returning an error. I have modified applications which attempt to do this - but am worried I might have missed one, and don't want it crashing an update. |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2011-04-12 : 10:59:58
|
| You could create a trigger that ignores any attempted update to the computed column. |
 |
|
|
lappin
Posting Yak Master
182 Posts |
Posted - 2011-04-12 : 11:13:02
|
quote: Originally posted by RickD You could create a trigger that ignores any attempted update to the computed column.
Could you give an example? |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2011-04-12 : 11:57:04
|
| Enough pseudo code to give you an idea..CREATE TRIGGER TR_WhateverINSTEAD OF INSERT , UPDATEAS...Check if insert or update here by querying the inserted and deleted tables...IF @var = 'U' --This is set from the query aboveIF UPDATE(CalcField)IGNOREELSEIF UPDATE(OtherFields)UPDATEIF @var = 'I'INSERT |
 |
|
|
lappin
Posting Yak Master
182 Posts |
Posted - 2011-04-15 : 11:13:55
|
| Thanks Rick. |
 |
|
|
|
|
|