Solved

Help with a trigger - calculated column

Posted on 2013-10-22
5
222 Views
Last Modified: 2013-10-22
I have a table with an end date column and a  long value that is a status.  I want to set the status to a specific value whenever the current date is great than the end date.  I know how to create a calculated column, but that requires a value in a column to change.  How do I trigger a value change based on the current date?
0
Comment
Question by:HLRosenberger
  • 3
  • 2
5 Comments
 
LVL 65

Expert Comment

by:Jim Horn
Comment Utility
>but that requires a value in a column to change.
Explain why this matters, as it's not clear why a calculated column can not meet your requirements.
0
 
LVL 1

Author Comment

by:HLRosenberger
Comment Utility
I could be all wet.   How/when does the comparision of the end date to current date take place?  I mean what triggers that?
0
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
Comment Utility
A trigger will fire when row(s) are inserted-updated-deleted, and gives the developer full control over what happens for the set of rows that are inserted-updated-deleted, and not for every row.

A calculated column is calculated on select, so in effect every time you access the column.
0
 
LVL 1

Author Comment

by:HLRosenberger
Comment Utility
Ah, so calculated should work then,   Thanks.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
Comment Utility
thanks.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to shrink a transaction log file down to a reasonable size.

772 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

11 Experts available now in Live!

Get 1:1 Help Now