Link to home
Start Free TrialLog in
Avatar of Bill Ross
Bill RossFlag for United States of America

asked on

What datatype corresponds to timestamp in SQL2016

According to Microsoft the timestamp data type has been depreciated.  I use MS Access as a front end to SQL and I've always used timestamp columns in tables where a yes/no (binary) field exists.  What data type is most correct?  Are timestamp columns still needed?

Thanks.
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

That is Binary. It is read-only in Access.

I've found that it sometimes is needed. It never hurts.

/gustav
Avatar of Bill Ross

ASKER

I have been doing it for years but now it's been "depreciated" in SQL 2016.  Should I use uniqueidntifier or ???

Thanks, Bill
I don't have 2016, but check for  a data type in SQL Server for RowVersion.

The point of the timestamp field in SQL Server was not to save a date time value, it was for SQL Server to use when comparing update when two users were attempting to update the same record.  I believe it has been replaced with RowVersion.

And you should not worry about this field in Access.

Dale
Hi Dale,

You're correct about the timestamp but as I recall from the past, 2003 days, there was an issue with Yes/No fields not updating properly from an Access front end against a SQL backend unless a timestamp field was added.  This may be no longer an issue but...

Thoughts?

Bill
I concur.  I always add a timestamp (row version) field to my SQL tables when I migrate from Access or if I'm going to be using the table in Access.  You also need to make sure that tables in SQL Server have a primary key if you intend to update them from within Access.
rowversion  is just a preferred synonym for timestamp:

rowversion (Transact-SQL)

It is not related specifically to Boolean fields, rather to keep track of (unexpected) updates of records.

/gustav
OK.  We're on the same page but timestamp is now "depreciated" according to Microsoft hence my question.  What's the replacement?

Thanks,

Bill
rowversion. Probably because it tells more precisely what the field is for.

/gustav
Hi Experts,

There is no rowversion data type native in SQL2016 but the timestamp sis still there.  This seems to be a non-issue.  Wonder why Microsoft says the timestamp is "depreciated" but still there and recommends a rowversion data type which must be created as a new data type but does the same thing???

I will probably close this one with a non-answer.

Thoughts?
There should be - according to the linked documentation above:

CREATE TABLE ExampleTable2 (PriKey int PRIMARY KEY, VerCol rowversion) ;

Open in new window

/gustav
Hi gustav,

Interesting.  When I run the create statement above and then script the table back out it gives me:

CREATE TABLE [dbo].[ExampleTable2](
      [PriKey] [int] NOT NULL,
      [VerCol] [timestamp] NOT NULL,
PRIMARY KEY CLUSTERED
(
      [PriKey] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

Also, if I look at it in designer the VerCol column shows a data type of timestamp...

Stranger still.  Seems like an alias or semantic issue more than a data type one.

Bill
That makes sense. Remember that MS called them synonyms.

Thanks for the info. Nice to have this confirmed.

/gustav
ASKER CERTIFIED SOLUTION
Avatar of Bill Ross
Bill Ross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Not a problem.  Info only.