Tema: išspręsta. Pvz. gal kam prireiks
Autorius: kl
Data: 2010-06-04 10:57:36
pradiniai duomenys (binary) reikia 02 pakeist  į 13 ir gražinti į DB
0x000000000000000000000100(02)000000A7BC


DECLARE @StrLength int

DECLARE @x VARBINARY(100); SET @x = (select Data from [ DB] where strname 
like '%qqq%' and ndataid = 13936)

--select @x AS 'Pradiniai duomenys'

DECLARE @y varchar (MAX); SET @y = (select master.dbo.fn_varbintohexstr(@x))

DECLARE @StrNew varchar (MAX)

SET @StrLength = (select LEN(@y))

SET @StrNew = (select ((select substring(@y, 0, 27)) + '13' + (select 
right(@y, @StrLength - 28))))

DECLARE @p VARBINARY (100)

set @p = (SELECT CAST('' AS XML).value('xs:hexBinary( 
substring(sql:variable("@StrNew"), sql:column("T.i")) )', 'varbinary(max)')

FROM (SELECT CASE SUBSTRING(@StrNew, 1, 2) WHEN '0x' THEN 3 ELSE 0 END) AS 
T(i))

--select @p AS 'Pakeisti'

UPDATE [InnerRangeInsight].[dbo].[TData]

SET [Data] = @p, --[bDirty] = 1

WHERE strname like '%qqq%' and ndataid = 13936

--select (select Data from [InnerRangeInsight].[dbo].[TData] where strname 
like '%qqq%' and ndataid = 13936) AS 'po keitimo is DB'



rezultatas

0x000000000000000000000100(13)000000A7BC