Solved

Default Constraint Question - SQL Server 2005

Posted on 2010-08-18
3
218 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now