Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Varbinary() Manipulations
Message
De
28/03/2001 15:33:59
 
 
À
28/03/2001 09:41:32
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00489405
Message ID:
00489609
Vues:
8
Look at the bitwise functions in T-SQL... from the BOL

Bitwise Operators
Bitwise operators perform bit manipulations between two expressions of any of the data types of the integer data type category.

Operator Meaning
& (Bitwise AND) Bitwise AND (two operands).
| (Bitwise OR) Bitwise OR (two operands).
^ (Bitwise Exclusive OR) Bitwise exclusive OR (two operands).

The operands for bitwise operators can be any of the data types of the integer or binary string data type categories (except for the image data type), with the exception that both operands cannot be any of the data types of the binary string data type category. The table shows the supported operand data types.

Left operand Right operand
binary int, smallint, or tinyint
bit int, smallint, tinyint, or bit
int int, smallint, tinyint, binary, or varbinary
smallint int, smallint, tinyint, binary, or varbinary
tinyint int, smallint, tinyint, binary, or varbinary
varbinary int, smallint, or tinyint


>I have a situation where I am trying to translate some VB code using some byte arrays into T-SQL code so I can run the functionality in a SQL stored procedure. I believe I have successfully converted most of the code but I'm stuck at the the point where there is some manipulation of the VB byte arrays and I don't quite see how I can do this in T-SQL ( or even if it's possible ). The relevant VB code is:
>Dim KEY_OFFSET As Long
>Dim bytKey() As Byte
>Dim bytData() As Byte
>Dim lNum As Long
>
>'...Set values for the various variables, then:
>
>For lNum = LBound(bytData) To UBound(bytData)
>    If lNum Mod 2 Then
>        bytData(lNum) = bytData(lNum) Xor (bytKey(lNum) + KEY_OFFSET)
>    Else
>        bytData(lNum) = bytData(lNum) Xor (bytKey(lNum) - KEY_OFFSET)
>    End If
>Next lNum
>I can ( or at least I think I can ) get most of the entities translated, i.e. the arrays bounds, Mod, and Xor I can translate. I am using T-SQL varbinary() for the equivalent VB byte arrays and the specific problem I am wrestling with is how to "replace" bits ( bytes? ) in the varbinary() variable like is done with the
>        bytData(lNum) = bytData(lNum) Xor (bytKey(lNum) + KEY_OFFSET)
>VB statement.
>
>Is this possible in T-SQL and if so, how?
>
>Thanks,
>Bill
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform