Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / SQL Server / ADP / May 2005

Tip: Looking for answers? Try searching our database.

Is there a Before Update Trigger with SQL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff - 03 May 2005 16:33 GMT
I would like to set the User_Name() and GetDate() in a table before my
insert and update triggers start. Is there a way of doing this before the
trigger? Right now I update these fields after the trigger but it ends up
causing an unnecessary re-trigger to update the fields and I don't want to
set the username and date on the front-end.
Graham R Seach - 04 May 2005 13:14 GMT
Jeff,

As with Jet, you can define a DefaultValue in SQL Server, using GetDate()
and SUSER_SNAME(). But SQL Server also allows you to specify INSTEAD OF
triggers, like so:

   CREATE TRIGGER procMyInsteadProc ON dbo.Table1
   INSTEAD OF INSERT
   AS
       INSERT INTO Table1 (MyDate, MyUser)
       VALUES (DateAdd(month, 1, GetDate()),
       SUSER_SNAME() + ' eats worms!')

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

>I would like to set the User_Name() and GetDate() in a table before my
> insert and update triggers start. Is there a way of doing this before the
> trigger? Right now I update these fields after the trigger but it ends up
> causing an unnecessary re-trigger to update the fields and I don't want to
> set the username and date on the front-end.
Jeff - 04 May 2005 14:52 GMT
Thanks, works like a charm
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.