one method to view binary (if the binary is really just text) in Database

Problem describe:

Very often we may find some binary column in SharePoint database, i.e. AllDocs -> MetaInfo, Webs -> MetaInfo. It is really just some text stored in binary format. However, since it is rendered in binary format when we run a query, it is hard to see.


There is a Cast function we can use to view what text those binary is (see below for a sample) 

select top 3 dirname, leafname,

Cast(Cast(metainfo AS VARBINARY(2048)) As varchar(2048)) as metainfo_text

from alldocs where metainfo is not null