Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server-2008
hello
 
I want to create table below table in which i have two computed column ,but there are some error msg while creating table,,,,,
CREATE TABLE [tblcaseprogress_old](
    [Et_id] [int] NOT NULL,
    [u_id] [int] NOT NULL,
    [registration] [int] NULL,
    [contact] [int] NULL,
    [property] [int] NULL,
    [expense] [int] NULL,
    [income] [int] NULL,
    [asset] [int] NULL,
    [liability] [int] NULL,
    [qa] [int] NULL,
    [hardship] [int] NULL,
    [suppdoc] [int] NULL,
    [rvsub] [int] NULL,
    [cobor] [int] NULL,
    [empinfo] [int] NULL,
    [financial] AS ((([income]+[expense])+[asset])+[liability]),
    [total]  AS ((((((([registration]+[contact])+[property])+[financial])+[qa])+[hardship])+[suppdoc])+[rvsub])
) ON [PRIMARY]
 
Error:
Computed column 'financial' in table 'tblcaseprogress_old' is not allowed to be used in another computed-column definition.
 

 
anything wrong from mine side,plz suggest me...
Posted 10-Sep-12 1:55am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hello,
 
"computed columns are virtual columns that are not physically stored in the table. Their values are recalculated every time they are referenced in a query. The Database Engine uses the PERSISTED keyword in the CREATE TABLE and ALTER TABLE statements to physically store computed columns in the table. Their values are updated when any columns that are part of their calculation change. By marking a computed column as PERSISTED."
 
So bottom line is practically its not possible.
 
Please refer below link for more details : http://msdn.microsoft.com/en-us/library/ms191250%28SQL.105%29.aspx
  Permalink  
Comments
Madhuri Patil at 10-Sep-12 10:22am
   
thanks from my side 5pts
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

try
CREATE TABLE [tblcaseprogress_old](
    [Et_id] [int] NOT NULL,
    [u_id] [int] NOT NULL,
    [registration] [int] NULL,
    [contact] [int] NULL,
    [property] [int] NULL,
    [expense] [int] NULL,
    [income] [int] NULL,
    [asset] [int] NULL,
    [liability] [int] NULL,
    [qa] [int] NULL,
    [hardship] [int] NULL,
    [suppdoc] [int] NULL,
    [rvsub] [int] NULL,
    [cobor] [int] NULL,
    [empinfo] [int] NULL,
    [financial] AS ((([income]+[expense])+[asset])+[liability]),
    [total]  AS ((((((([registration]+[contact])+[property])+((([income]+[expense])+[asset])+[liability]))+[qa])+[hardship])+[suppdoc])+[rvsub])
) ON [PRIMARY]
  Permalink  
Comments
Madhuri Patil at 10-Sep-12 8:06am
   
great,and thanks for ur rply,
I have already apply this solution from my side,
but purpose of asking this,can this possible which i have created table structure above(in my question),
__TR__ at 10-Sep-12 8:17am
   
I don't understand "can this possible which i have created table structure above".
What is possible ?
Madhuri Patil at 10-Sep-12 8:37am
   
please read my question carefully,i have asked that,
"How to use one computed column in another computed column" in sqlserver.
__TR__ at 10-Sep-12 8:39am
   
You can not use one computed column inside other computed column.
Madhuri Patil at 10-Sep-12 8:50am
   
if i need to do in this way then what solution u have to suggest me,,,
__TR__ at 10-Sep-12 9:06am
   
I am sorry i did not understand your question.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

use
[total] AS ((((((([registration]+[contact])+[property])+([income]+[expense]+[asset]+[liability])+[qa])+[hardship])+[suppdoc])+[rvsub])
this solution Miss Desale Ji...
  Permalink  
Comments
Madhuri Patil at 11-Sep-12 6:05am
   
Thanks for rply
and this solution alredy posted,i expect other than above solutions,
and what is this ,Miss Desale ji.. how u know?
Devang Vaja at 11-Sep-12 6:22am
   
i Know u...Open Your FB der will Be MY request

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 424
1 Nirav Prabtani 298
2 OriginalGriff 199
3 _Amy 165
4 Maciej Los 145
0 OriginalGriff 7,755
1 Sergey Alexandrovich Kryukov 6,951
2 Maciej Los 3,994
3 Peter Leow 3,698
4 CHill60 2,742


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 11 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100