日期:2014-05-18  浏览次数:20582 次

很难得update 高手们来看看。。只更新某数据。
比如,数据如下.
在.user表中的字段.
用户名 数据.
123 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0200FF00000001000000000000000000FFFFFFFFFFFFFFFFF
  FFFFF1100FFFFFFFFF31F0000000000000000FFFFFFFFF1000FFFFFFFFF71F0000000000000000

红色部分是要改的。而。FFFFFFFFFFFFFFFF为空的数据。不能去改。
这样的有办法修改吗??

------解决方案--------------------
SQL code

CREATE TABLE #USER
       ([用户] VARCHAR(10),
        [数据] VARCHAR(1000))
INSERT #USER
SELECT '123','0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0200FF00000001000000000000000000FFFFFFFFFFFFFFFFFFFFFF1100FFFFFFFFF31F0000000000000000FFFFFFFFF1000FFFFFFFFF71F0000000000000000' UNION ALL
SELECT '456','0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0200FF00000001000000000000000000FFFFFFFFFFFFFFFFFFFFFF1100FFFFFFFFF31F0000000000000000FFFFFFFFF1000FFFFFFFFF71F0000000000000000'

UPDATE #USER
   SET [数据]=REPLACE([数据],'02','88')   
WHERE [用户]='456'

UPDATE #USER
   SET [数据]=REPLACE([数据],'1000','8888')   
WHERE [用户]='456'

UPDATE #USER
   SET [数据]=REPLACE([数据],'1100','8888') 
WHERE [用户]='456'

UPDATE #USER
   SET [数据]=REPLACE([数据],'31F','888')   
WHERE [用户]='456'

SELECT * FROM #USER

/*
用户         数据
---------- ----------------------------------------------------------------------------------------------------------------
123        0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0200FF00000001000000000000000000FFFFFFFFFFFFFFFFFFFFFF1100FFFFFFFFF31F0000000000000000FFFFFFFFF1000FFFFFFFFF71F0000000000000000
456        0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8800FF00000008888000000000000000FFFFFFFFFFFFFFFFFFFFFF8888FFFFFFFFF8880000000000000000FFFFFFFFF8888FFFFFFFFF71F0000000000000000
*/