There's an undocumented function to convert a binary value to a hex string:
SELECT master.dbo.fn_varbintohexstr(0x000000000000102B)
However, it's not a good idea to include undocumented features in production
code so I suggest you write your own function. You can reverse engineer
this system function if needed.
--
Hope this helps.
Dan Guzman
SQL Server MVP
[quoted text, click to view] "Vince Marciano" <marcianov@epa.nsw.gov.au> wrote in message
news:00cf01c3b3de$4e37d7a0$a001280a@phx.gbl...
> Hi,
>
> I am passing an XML text stream into a stored procedure
> which contains a timestamp field for me to use as the way
> to handle concurrency. I can retrieve each of the elements
> in the XML stream. My problem is the timestamp field comes
> in as a character string e.g.
> <row_timestamp>0x000000000000102B<\row_timestamp> and I
> want to use this in my where clause to ensure that no one
> else has updated the record since I retrieved it.
>
> I need to be able to convert the row_timestamp in the XML
> stream to a datatype of timestamp or be able to convert
> the column in my table to a comparable datatype.
>
> When I use cast(row_timestamp as char(18)) I get back
> nothing for the value. If I use cast(cast(row_timestamp as
> char(18)) AS binary(8)) I get back a value that is the
> same to what is in the XML stream but of a different type
> which are not comparable.
>
> If I go the other way if I use:
> CAST('0x000000000000102B' AS timestamp)
> then I get the result: 0x3078303030303030 which is not the
> same value.
>
> Can someone please help me or comfirm that this is not
> able to be done.
>
> Regards,
> Vince Marciano