sql server - How can I substitute IDs in a string with corresponding values from a table? -


i've got 2 tables in sql server 2008 r2 database - rules , items

a rules record has id , expression, eg:

  1, "(1 , 2)" 

an items record has id , name, eg:

  1, "foo"    2, "bar" 

is there way select rule expressions , substitute items ids names in single query?

select magic(expression) rules id = 1 

will give me "(foo , bar)"

i'm thinking of doing .net console app, can leverage regex, if there's way in sql, isn't messy, i'd rather go route.

there's thing called clr stored procedure. msdn clr stored procedure

so use regex .net. it's not fast though. simple rule string functions in sql, more complex ones cause serious pain. think i'd tempted outside of sql myself, if there's lot of it.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -