Hi,
I have a situation where some data is stored in a comma separated format. One cell in this table can mean many rows in another table (i.e. answers 'top', 'middle' and 'bottom' can all be represented by '1,1,1', where as 'top' and 'bottom' would be represented as '1,0,1').
Now, to count which options have been selected, I use a cursor to select one data cell (comma separated value) at a time and then process this; loop through the string checking for a '1' and then look up the full string answer in a table variable.
Now, looking at SQL profiling tool, this does seem to have a bit of a performance impact. I will be caching the results of this query, but still want to optimise queries at every possible opportunity. Unfortunatly I am unable to change how this data is stored...
So, is there a better way to take a comma separated representation of data and get the underlying data in a less expencive way?
Thanks for reading.
I have a situation where some data is stored in a comma separated format. One cell in this table can mean many rows in another table (i.e. answers 'top', 'middle' and 'bottom' can all be represented by '1,1,1', where as 'top' and 'bottom' would be represented as '1,0,1').
Now, to count which options have been selected, I use a cursor to select one data cell (comma separated value) at a time and then process this; loop through the string checking for a '1' and then look up the full string answer in a table variable.
Now, looking at SQL profiling tool, this does seem to have a bit of a performance impact. I will be caching the results of this query, but still want to optimise queries at every possible opportunity. Unfortunatly I am unable to change how this data is stored...
So, is there a better way to take a comma separated representation of data and get the underlying data in a less expencive way?
Thanks for reading.