Home > Ask the SQL Server Experts > Archive: Development Questions & Answers > Executing a trigger before SQL Server table is updated
Ask The SQL Server Expert: Questions & Answers
EMAIL THIS

Executing a trigger before SQL Server table is updated

Greg Low EXPERT RESPONSE FROM: Greg Low

Pose a Question
Other SQL Server Categories
Meet all SQL Server Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 11 September 2007
Can I execute a trigger before an insert is created to a table. I need to create logging on the CRM system, but I do not have access to modify the CRM. Can I grab incoming values from the table and based on the ID, read and extract with a trigger before the table is updated?


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
SQL/Transact SQL (T-SQL)
SQL language crash course (just enough to be dangerous)
Working with IntelliSense in SQL Server 2008 Management Studio
SQL Server Mailbag: Stored procedures, triggers and SSRS reports
Working with sparse columns in SQL Server 2008
Determining the source of full transaction logs in SQL Server
New GROUP BY option provides better data control in SQL Server 2008
Using the OPENROWSET function in SQL Server
Loading data files with SQL Server's BULK INSERT statement
Importing and exporting bulk data with SQL Server's bcp utility
Testing transaction log autogrowth behavior in SQL Server
SQL/Transact SQL (T-SQL) Research

SQL Server Stored Procedures
SQL Server Mailbag: CALs, witnesses and unwanted changes
SQL Server Mailbag: Stored procedures, triggers and SSRS reports
Top tips and tricks for SQL Server database development
Top 10 SQL Server development tips of 2008
SQL Server trigger vs. stored procedure to receive data notification
SQL Server errors, failures and other problems fixed from the trenches
SQL Server and data manipulation in T-SQL
How to use SQL Server 2008 hierarchyid data type
SQL Server stored procedures tutorial: Write, tune and get examples
Check SQL Server database and log file size with this stored procedure

Archive: Development
Copy stored procedure between SQL Server 2005 databases
Should developers have permissions to SQL Server production queue?
Schedule stored procedure and save output to network drive
Query to find SQL Server database names created by users
Is it possible to find disabled indexes in SQL Server 2000?
SQL Server id permission to create and modify tables
Problem attaching stored procedure and SQL Server trigger
Installing different SQL Server versions on one machine
Calling an extended stored procedure in SQL Server 2005
Multiple SQL Server instances vs. multiple databases

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
ACID  (SearchSQLServer.com)
Collaboration Data Objects  (SearchSQLServer.com)
commit  (SearchSQLServer.com)
container  (SearchSQLServer.com)
DAO  (SearchSQLServer.com)
fetch  (SearchSQLServer.com)
OLE DB  (SearchSQLServer.com)
query  (SearchSQLServer.com)
SQL  (SearchSQLServer.com)
T-SQL  (SearchSQLServer.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


You can, by creating an INSTEAD OF TRIGGER. However, I suspect you're really asking about an UPDATE trigger (by your description). Even AFTER triggers (ie the default type) allow you access to both the before and after versions of the data via the deleted and inserted virtual tables.

Check out this helpful tip:   
  • Optimize database triggers in SQL Server 2000
    It's hard to follow the logic behind triggers and easy to forget about them in time. Why and when should you use them? Learn about performance issues and design considerations.



  • Search and Browse the Expert Answer Center
    Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
    Browse our Expert Advice



    SQL Solutions - SQL Database Design
    HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Site Map




    All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts