sql server - How do you convert VARCHAR to TIMESTAMP in MSSQL? -
you'd call stored proc on ms sql has parameter type of timestamp within t-sql, not ado.net using varchar value (e.g. '0x0000000002c490c8').
what do?
update: have "timestamp" value coming @ exists varchar. (think output variable on stored proc, it's fixed varchar, has value of timestamp). so, unless decide build dynamic sql, how can programmatically change value stored in varchar valid timestamp?
a timestamp datatype managed sql server. i've never seen used anywhere other table column type. in capacity, column of type timestamp give rigorous ordinal of last insert/update on row in relation other updates in database. see recent ordinal across entire database, can retrieve value of @@dbts or rowversion().
per http://msdn.microsoft.com/en-us/library/ms182776(sql.90).aspx
timestamp (transact-sql)
is data type exposes automatically generated, unique binary numbers within database. timestamp used mechanism version-stamping table rows. storage size 8 bytes. timestamp data type incrementing number , not preserve date or time. record date or time, use datetime data type.
hence, volatile value of timestamp column cannot set , subject change upon modifaction row. can, however, freeze timestamp value varbinary(8) value.
for example, had source table , target table.
create table tblsource (
id int not null
coldata int not null
coltimestamp timestamp null)
create table tbltarget (
id int not null
coldata int not null
coltimestampvarbinary varbinary(8) null)
then, in extraction process, might want capture has been updated since last time ran extraction process.
declare @maxfrozentargettimestamp varchar(8)
select @maxfrozentargettimestamp = max(colstamp) tbltarget
insert tbltarget(id, coldata, coltimestampvarbinary)
select
id
,coldata
, coltimestampvarbinary = convert(varbinary(8) coltimestamp)
from
tblsource
where
tblsource.coltimestamp > @maxfrozentargettimestamp
if having issues, first guess crux of problem in conversion of varchar varbinary(8), , not timestamp type.
for more info (perhaps much) , see comment (fourth 1 down) left blog post http://vadivel.blogspot.com/2004/10/about-timestamp-datatype-of-sql-server.html?showcomment=1213612020000
Comments
Post a Comment