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 |
V.V.
Starting Member
32 Posts |
Posted - 2012-09-20 : 03:57:25
|
Hello,I have a table which has 3 computed columns nvarchar type. I need to insert some data into this table and I get this error:"The column "Address1" cannot be modified because it is either a computed column or is the result of a UNION operator."How can I insert data or update these 3 columns directly from script? |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-09-20 : 04:14:53
|
Just change only the other two columns... Too old to Rock'n'Roll too young to die. |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2012-09-20 : 04:15:44
|
You cann't insert / update the data in Computed column, because computed column doesn't store the actual data, it just hold the expesion/formula of the column.There are a few rules to follow when you are dealing with computed columns:•Columns referenced in the computed-column expression must be in the same table.•The computed-column expression cannot contain a subquery.•Computed columns cannot be used as any part of keys or indexes; this includes Fkeys, Pkeys, and unique indexes.•A computed column cannot have a DEFAULT constraint attached to it.•Computed columns cannot receive INSERT or UPDATE statements.Senthil Kumar C------------------------------------------------------MCITP - Database Administration SQL SERVER 2008MCTS - Database Development SQL SERVER 2008 |
|
|
V.V.
Starting Member
32 Posts |
Posted - 2012-09-20 : 04:34:13
|
#webfred, can you elaborate a little bit your idea?By change the other columns you mean to drop formula from computed columns, insert data and after that write formula again?I tried this but won't let me save these changes on the specific table. It says to drop it and recreate it. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-09-20 : 04:46:15
|
you cannot insert data into a computed column. The computed column value will automatically changed when the value of the other column(s) where the formula is based on changes KH[spoiler]Time is always against us[/spoiler] |
|
|
|
|
|