Results 1 to 5 of 5
  1. #1
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067

    SQL Server Trigger Question


    I need to set up a trigger so that when a new record is created a field in my table is populated with the getdate() Function. I'm new to triggers and would appreciate some pointers on how to set this trigger up. In Access I could just give the field a default value but I can't find that property in SQL. Any help would be appreciated.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    SQL Server also has default values. You should see it in design view.

    A picture if needed.

    Click image for larger version. 

Name:	Default.jpg 
Views:	14 
Size:	28.3 KB 
ID:	11974
    Last edited by June7; 04-18-2013 at 06:10 PM. Reason: merge posts
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    If not set up in table, why not DefaultValue property of textbox on form?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067
    June7 the idea is that this field is not entered by the user it gives the date the record was created.
    PBaldy thanks, that worked interestingly if you go to the properties of the field in SQL Server Management Studio that option is not available. If you go to the design of the table and click on that field the option is available there. That's why I couldn't find it.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No problem. June's method would work, but setting it at the table level is more bullet proof, and simpler than a trigger.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Trigger event with button click
    By AMAS in forum Forms
    Replies: 8
    Last Post: 06-07-2012, 09:42 AM
  2. event to trigger after new record
    By richlyn in forum Access
    Replies: 1
    Last Post: 03-02-2012, 10:26 AM
  3. A question about client/server
    By kosti in forum Access
    Replies: 1
    Last Post: 12-06-2011, 08:22 AM
  4. date trigger
    By hyperionfall in forum Access
    Replies: 1
    Last Post: 08-08-2010, 01:15 PM
  5. Trigger subform event
    By tuna in forum Forms
    Replies: 0
    Last Post: 05-09-2010, 06:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums