N Raghu
N Raghu

Reputation: 746

cast or convert varchar datatype to rowversion

I am able to convert rowversion column in a table to varchar using below code

select CONVERT(VARCHAR, CONVERT(BINARY(8), roversion_col), 1) rwa from TBL

How do I convert it back to rowversion datatype? Is it NOT possible to do so?

Update:
This should not be treated as duplicate with How to convert TIMESTAMP values to VARCHAR in T-SQL as SSMS does?

That question is about asking rowversion datatype to varchar. However, this question is vice-versa and wanted to get rowversion data using varchar.

Upvotes: 1

Views: 2831

Answers (1)

Alex
Alex

Reputation: 31

Try this:

CONVERT(rowversion, CONVERT(BINARY(8), @teststring, 1))

Upvotes: 3

Related Questions