Friday, September 05, 2008

To retrieve data stored in varbinary data type column

Varbinary data type can store Variable-length binary data with maximum size of 8,000 bytes. The storage size is the actual length of the data entered + 2 bytes. Column of this type can be used to store data such as images, sounds, video, Office documents, compressed data and other non-alphanumeric data.

Sample:To get password stored in SQL server table.
Table 'Users' have a field 'Password' with data type 'varbinary(50)'.
Run the following query to get password from the 'Password' field of the table 'Users' .

SELECT UserID, FirstName, LoginName, Convert(nvarchar(50),Password) FROM Users

No comments: