Código PHP:
DECLARE @Acc varchar(10), @Inv BINARY(1200), @ItemSerial BINARY(3), @Item BINARY(10), @cnt INTEGER
DECLARE LISTA CURSOR LOCAL FOR
SELECT AccountID FROM warehouse
OPEN LISTA
FETCH NEXT FROM LISTA INTO @Acc
WHILE @@FETCH_STATUS = 0
BEGIN
SET @Inv = (SELECT items FROM [warehouse] WHERE (AccountID=@Acc))
SET @cnt = 1
WHILE (@cnt <= (LEN(@Inv)/2))
BEGIN
SET @Item = SUBSTRING(@Inv,@cnt,10)
SET @ItemSerial = SUBSTRING(@Item,5,3)
/* Colocar codigo Binario */
IF (@ItemSerial = 0x000000)
BEGIN
print 'Yep! We got a 0x0 serial!'
print 'Account: '+@Acc
print 'Item: '; print @Item
print '--------------------------'
END
SET @cnt = @cnt + 10
END
FETCH NEXT FROM LISTA INTO @Acc
END
CLOSE LISTA
DEALLOCATE LISTA
espero su ayuda, gracias