Default values


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Default values

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Default values

    [Originally posted by Yogesh]

    Hi ,

    In my application i m using a date time column for all the tables for keeping track of Modified date time.
    I m using SQL Server 7.0
    Now I have mentioned a default value in the Defaults pane of the SQL Server Entriprise Manager and bound that default to the modified date time columns.

    So now I don't have to mention the value each time in the Insert statement when executing from the front end (VB Client).


    But what In case of update statements !!! I have to mention the column and the value isn't it ? Can I do something by which in the update statement also I don't have to specify the column and the value, it should take it System date by default always.

    Plz reply urgently.

    Thanks
    Yogesh



  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Default values

    [Originally posted by Charlie Zimmerman]

    You can write a trigger. The trigger will look something like this:

    CREATE TRIGGER UPDATE_DATE ON [dbo].[MYTABLE] FOR UPDATE AS
    UPDATE MYTABLE SET LASTUPDATEDATE = getdate() from
    MYTABLE, inserted
    WHERE MYTABLE.ID = inserted.ID

    In the above, change the following:

    MYTABLE -> Your table name
    LASTUPDATEDATE -> Name of Date/Time Stamp Field
    ID -> Name of Identity Field

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center