如何在另一个计算列中使用一个计算列 [英] How to use one computed column in another computed column

查看:111
本文介绍了如何在另一个计算列中使用一个计算列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我想在其中有两个计算列的表下面创建表,但是在创建表时出现错误,msg ,,,,

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]



错误:
表"tblcaseprogress_old"中的计算列"financial"不允许在另一个计算列定义中使用.



我这边有什么问题,请给我建议...



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...

推荐答案

你好,

计算列是未物理存储在表中的虚拟列.每次在查询中引用它们时,都会重新计算它们的值.数据库引擎在CREATE TABLE和ALTER TABLE语句中使用PERSISTED关键字将计算列实际存储在表中的值.当计算中包含的任何列发生更改时,它们的值都会更新.通过将计算出的列标记为PERSISTED."

所以底线实际上是不可能的.

请参考下面的链接以获取更多详细信息:http://msdn.microsoft.com/zh-cn/library/ms191250%28SQL.105%29.aspx
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


try
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]


使用
[总计] AS((((((((((注册)] + [联系人])+ [属性])+([收入] + [费用] + [资产] + [责任])+ [qa])+ [困难])+ [suppdoc])+ [rvsub])
这个解决方案Desale Ji小姐...
use
[total] AS ((((((([registration]+[contact])+[property])+([income]+[expense]+[asset]+[liability])+[qa])+[hardship])+[suppdoc])+[rvsub])
this solution Miss Desale Ji...


这篇关于如何在另一个计算列中使用一个计算列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆