Microsoft, SQL Server, Technical

Convert column data from Binary to String with SQL Server 2005

I had this binary column in SQL Server 2005 which was storing the MD5 hashes of certain files. The requirement was to display these hashes in a ASP.NET web UI. So i set about the task of converting the same. Binary data as such cannot be displayed on the UI. It needs to be converted to String. So you could go ahead and read byte by byte and convert it into a string, concatenating it as you go along. To facilitate things, SQL Server comes built in with a function that could convert common data types to string. It is called:

sys.fn_sqlvarbasetostr

The above function will in turn call

sys.fn_varbintohexsubstring

in our case because we are trying to convert binary to string. To use the function in a select query just do so:

SELECT sys.fn_sqlvarbasetostr(MD5Hash) From HashTable

where MD5Hash is the binary column you would like to convert.

Perforce, Technical

Error: Can’t clobber writable file Perforce

We use Perforce in our organization for Source Control. I was trying to get the latest revision for some of the files that were updated by other developers. and noticed the following error:

Can’t clobber writable file

I knew for a fact that files under source control were marked as read-only and when a file is checked out, then it removes the read-only attribute. So deciding to check on that I found that all the files under my perforce folder were not read-only. I went ahead and marked every file as read-only, and was able to get the latest revision without any errors. Cool, another problem solved.