Home All Groups Group Topic Archive Search About
Author
12 Aug 2005 2:42 PM
Ata Giray
Hi,
in which cases can we use timestamp datatype?

thanks


*** Sent via Developersdex http://www.developersdex.com ***

Author
12 Aug 2005 2:53 PM
Adam Machanic
It's generally used for keeping track of row modifications.  Keep in mind
that it has nothing to do with time or date.

It automatically updates itself when a modification occurs:

---
CREATE TABLE #MyTable (SomeCol INT, theTimeStamp TIMESTAMP)

INSERT #MyTable (SomeCol) VALUES (1)

SELECT *
FROM #MyTable

UPDATE #MyTable
SET SomeCol = 2

SELECT *
FROM #MyTable

DROP TABLE #MyTable
---

If your application requires action to be taken when rows are updated, it
can be a useful tool.


--
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--


Show quoteHide quote
"Ata Giray" <atagi***@yahoo.com> wrote in message
news:uevziw0nFHA.2860@TK2MSFTNGP15.phx.gbl...
> Hi,
> in which cases can we use timestamp datatype?
>
> thanks
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
Author
12 Aug 2005 2:53 PM
Aaron Bertrand [SQL Server MVP]
It is usually used for optimistic concurrency, and if you use it, you should
refer to the data type "ROWVERSION" to avoid ambiguity.  This data type does
*NOT* have anything to do with date or time (it has a very misleading name).




Show quoteHide quote
"Ata Giray" <atagi***@yahoo.com> wrote in message
news:uevziw0nFHA.2860@TK2MSFTNGP15.phx.gbl...
> Hi,
> in which cases can we use timestamp datatype?
>
> thanks
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
Author
12 Aug 2005 2:57 PM
Mike Epprecht (SQL MVP)
From BOL:

"timestamp is a  data type that exposes automatically generated binary
numbers, which are guaranteed to be unique within a database. timestamp is
used typically as a mechanism for version-stamping table rows. The storage
size is 8 bytes."

Generally you can use it in an application for concurrency control.

Regards
--------------------------------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/



Show quoteHide quote
"Ata Giray" wrote:

> Hi,
> in which cases can we use timestamp datatype?
>
> thanks
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
>