The bitwise_xor() Scalar Function : bitwise operators « Data Types « SQL Server / T-SQL Tutorial

SQL Server / T-SQL Tutorial
1. Query
2. Insert Delete Update
3. Table
4. Table Join
5. Data Types
6. Set Operations
7. Constraints
8. Subquery
9. Aggregate Functions
10. Date Functions
11. Math Functions
12. String Functions
13. Data Convert Functions
14. Analytical Functions
15. Sequence Indentity
16. View
17. Index
18. Cursor
19. Database
20. Transact SQL
21. Procedure Function
22. Trigger
23. Transaction
24. XML
25. System Functions
26. System Settings
27. System Tables Views
28. User Role
29. CLR
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
SQL Server / T-SQL Tutorial » Data Types » bitwise operators 
5. 3. 13. The bitwise_xor() Scalar Function
5>
6CREATE FUNCTION dbo.bitwise_xor(
7>   @arg1 varbinary(8),
8>   @arg2 varbinary(8)
9RETURNS varbinary(8)
10> AS
11BEGIN
12>   DECLARE
13>     @result   AS varbinary(8),
14>     @numbytes AS int,
15>     @curpos   AS int
16>   SET @result   = 0x
17>   SET @numbytes = DATALENGTH(@arg2)
18>   SET @curpos   = 1
19>   WHILE @curpos <= @numbytes
20>   BEGIN
21>     SELECT
22>       @result = @result + CAST(SUBSTRING(@arg1, @curpos, 1^
23>                                CAST(SUBSTRING(@arg2, @curpos,1)
24>                                  AS tinyint)
25>                             AS binary(1))
26>     SET @curpos = @curpos + 1
27>   END
28>   RETURN @result
29END
30> GO
1> GRANT EXECUTE ON dbo.bitwise_xor TO public
2> GO
1>
2SELECT dbo.bitwise_xor(0x00000001000000010000000100000001,
3>                        0xffffffffffffffffffffffffffffffff)
4>
5> drop function dbo.bitwise_xor
6> GO





------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
----------------------------------
0xFFFFFFFEFFFFFFFE





(rows affected)
1>
2>
5. 3. bitwise operators
5. 3. 1. Selecting data using bitwise operators.
5. 3. 2. Testing numeric values with bitwise operators.
5. 3. 3. Bitwise NOT (~) Validity Table
5. 3. 4. Legal Bitwise Operation
5. 3. 5. Retrieving Index Properties by Using the Bitwise AND (&) Operator
5. 3. 6. Bitwise AND (&)
5. 3. 7. Bitwise OR (|)
5. 3. 8. Exclusive Or (^)
5. 3. 9. Bitwise NOT (~)
5. 3. 10. The bitwise_not() Scalar Function
5. 3. 11. The bitwise_and() Scalar Function
5. 3. 12. The bitwise_or() Scalar Function
5. 3. 13. The bitwise_xor() Scalar Function
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.