Results 1 to 6 of 6

Thread: timestamp

  1. #1
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183

    Unhappy Unanswered: timestamp

    If i have a table with a 3 fields and one of them has a timestamp as a field type and I want to do an insert or update what is the value I am inserting for the column timestamp.

    Help appreciated

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    don't

    that's how you work with timestamps, you don't provide the value, sql server does automatically on inserts and updates
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Are you working with a Sybase/Microsoft timestamp, meaning a binary widget that changes automagically whenever something in the database changes, or a SQL-92 timestamp which is a conventional datetime value that is automagically deposited once when the row is created? The difference is crucial to the answer to your question.

    -PatP

  4. #4
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183
    Sorry, I am working Microsoft.

    I have done the update as I have read that I just need to use DEFAULT and it inserts the next available.

    Insert into Test values ('blah','blah',DEFAULT,'blah') and that seems to have created a unique value.

    Do you think that is fine?

    Cheers

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by zobernjik
    Sorry, I am working Microsoft.
    don't apologize, this is, after all, the Microsoft SQL Server forum

    what pat was thinking about was this --
    Quote Originally Posted by BOL
    The Transact-SQL timestamp data type is not the same as the timestamp data type defined in the SQL-92 standard. The SQL-92 timestamp data type is equivalent to the Transact-SQL datetime data type.

    A future release of Microsoft® SQL Server™ may modify the behavior of the Transact-SQL timestamp data type to align it with the behavior defined in the standard. At that time, the current timestamp data type will be replaced with a rowversion data type.

    Microsoft® SQL Server™ 2000 introduces a rowversion synonym for the timestamp data type. Use rowversion instead of timestamp wherever possible in DDL statements.
    Insert into Test values ('blah','blah',DEFAULT,'blah') and that seems to have created a unique value.

    Do you think that is fine?
    yes, but i think it's better to list the specific columns you're providing values for, and therefore you would omit the timestamp column --

    Insert into Test (col1,col2, col4) values ('blah','blah', 'blah')
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183
    thanks guys

Posting Permissions

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