Solved

Default Constraint Question - SQL Server 2005

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

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…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 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