SQL Server 2000 - Substring or replace for a binary value

  • How to substring or replace 0x from a binany value 0xF60F9125DBA7E94012F55E2177C95C0E906862B1

    in SQL Server 2000 using tsql. The output should be F60F9125DBA7E94012F55E2177C95C0E906862B1

  • your string = 0xF60F9125DBA7E94012F55E2177C95C0E906862B1

    try this in your SQL Statement

    REPLACE ( '0xF60F9125DBA7E94012F55E2177C95C0E906862B1' , '0x' , '' )

    Good Luck...

  • You can use substring in SQL 2000

    Here is an example:

    declare @fg char(100)

    set @fg = '0xF60F9125DBA7E94012F55E2177C95C0E906862B1'

    select @fg

    select substring(@fg, 3, 98)

  • Thank you all for the responses. Substring and replace will not work on binary value unless we do the conversion to a string, did the conversion in the following way and it worked

    replace(upper(master.dbo.fn_varbintohexstr('0xF60F9125DBA7E94012F55E2177C95C0E906862B1'

    )),'0x','')

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply