标签:
原文:.SQL Server中 image类型数据的比较IF object_id(‘compare_image‘) IS NOT NULL DROP FUNCTION compare_image GO create function compare_image(@a1 image, @a2 image) returns int -- if match, return 1 as begin declare @n int, @i int, @j int declare @b1 varbinary(8000), @b2 varbinary(8000) set @n = 1 if datalength(@a1) <> datalength(@a2) -- different length set @n = 0 else begin set @i = 0 set @j = (datalength(@a1) - 1) / 8000 + 1 while @i <= @j begin set @b1 = substring(@a1, @i * 8000 + 1, case @i when @j then datalength(@a1) % 8000 else 8000 end) set @b2 = substring(@a2, @i * 8000 + 1, case @i when @j then datalength(@a2) % 8000 else 8000 end) if @b1 <> @b2 begin set @n = 0 break end set @i = @i + 1 end end return(@n) end go
标签:
原文地址:http://www.cnblogs.com/lonelyxmas/p/5773907.html