Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2005
    Posts
    115

    Unanswered: ALTER TABLE dateAuto

    I must add to an existing TABLE a column DateInsert
    with a default value = date auto
    if a new row is added the column must add datetime.now automaticly (like in acccess 2000) how can I do it ?

    for MS SQL 2000

    thank you

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Code:
    CREATE TABLE #patp (
       id		INT		IDENTITY
    ,  asof		DATETIME	NOT NULL
       DEFAULT GetDate()
    ,  other	VARCHAR(10)	NULL
       )
    
    INSERT #patp (other) VALUES ('One')
    INSERT #patp (other) VALUES ('Two')
    INSERT #patp (other) VALUES ('Three')
    
    SELECT * FROM #patp
    -PatP

  3. #3
    Join Date
    Dec 2002
    Posts
    1,245
    alter table MyTable Add
    DateAuto datetime CONSTRAINT DF_DateAuto DEFAULT (GetDate())
    Have you hugged your backup today?

  4. #4
    Join Date
    Jun 2005
    Posts
    115
    thank you Pat Phelan and hmscott

    great ! and fast !!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •