I have 7 bit binary data stored in a SQL Server database as varchar. This 7 bit binary data ultimately needs to be converted into an int. I was attempting to take this binary string and then convert to varbinary and then convert to integer. The cast to varbinary can accept a hex string, but I'm unable to find a way for this cast to accept a binary string.
Example strings:
0000010
0000100
0001001
These should convert to:
2
4
9
I could create a CLR function to call a C# function, but I was hoping to do this all in T-SQL.