Solved

Default Constraint Question - SQL Server 2005

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

27 Experts available now in Live!

Get 1:1 Help Now