For my application I dump some values into a column of varbinary(max). Now I'm trying to fetch the data from there again an would like to get a list from sql back with all values.
Within my C# application I perform the following task:
Data = ints.SelectMany(BitConverter.GetBytes).ToArray();
This Data is then inserted into the database.
What I'm looking for is a SQL script on how to retrieve the data, not simply as a blob, but as a list of all values. So something like this:
SELECT * FROM RawData CROSS APPLY CastToInt(SplitBinary(RawData.Data, 4)) WHERE RawDataId = 1;
Anyone know of a way to implement this kind of feature?
As background info, I'm trying to create a graph of a RawData within Grafana.
One method to split the 32-bit int values is with a binary string split function. The TVF example below uses a utility tally table to facilitate the task.
Tally table DDL:
Binary int split TVF:
Example usage: