Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Default Constraint Question - SQL Server 2005

Posted on 2010-08-18
3
223 Views
Last Modified: 2012-05-10
Hi,
I was looking at documentation from Microsoft about their AdventureWorks Database :
http://msdn.microsoft.com/en-us/library/ms124879(v=SQL.100).aspx

In their SalesOrderHeader table, they have a column "SubTotal" that they define  as :
     Sales subtotal:  Computed as SUM(SalesOrderDetail.LineTotal) for the SalesOrderID.

Q:  Can this be coded as a contraint or are they referring to the application computing this value?

Thanks much in advance,
hefterr
0
Comment
Question by:hefterr
  • 2
3 Comments
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 33470352
It is being computed by a trigger on the detail table, see trigger  SalesLT.[iduSalesOrderDetail]
0
 
LVL 1

Author Comment

by:hefterr
ID: 33470453
Hi cyberkiwi,
Thanks for the answer BUT could you please point me to this reference.  I am not familiar with using triggers.

Thanks,
hefterr
0
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 total points
ID: 33470687
There is no reference.
Go directly to the database in SSMS and inspect it.

The SubTotal is defined as just a simple column, not a computed column.
Also, looking at table iduSalesOrderDetail and expanding to Triggers, you see the trigger there.  Right-click modify reveals the calculation used to update the header whenever something interesting happens to a detail record.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQl server restarts itself 6 40
SQL Server 208R2 not recognizing DBF file in linked Server 11 60
Stored procedure 4 35
how many extra RAM for SQL server is needed 22 43
This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question