I have text stored in the table "StructureStrings"
Create Table StructureStrings(Id INT Primary Key,String nvarchar(4000))
Sample Data:
Id String
1 Select * from Employee where Id BETWEEN ### and ### and Customer Id> ###
2 Select * from Customer where Id BETWEEN ### and ###
3 Select * from Department where Id=###
and I want to replace the "###" word with a values fetched from another table named "StructureValues"
Create Table StructureValues (Id INT Primary Key,Value nvarcrhar(255))
Id Value
1 33
2 20
3 44
I want to replace the "###" token present in the strings like
Select * from Employee where Id BETWEEN 33 and 20 and Customer Id> 44
Select * from Customer where Id BETWEEN 33 and 20
Select * from Department where Id=33
PS: 1. Here an assumption is that the values will be replaced with the tokens in the same order i.e first occurence of "###" will be replaced by first value of "StructureValues.Value" column and so on.
nvarchar(40000)isnvarchar(4000)?nvarchar(40000)is an invalid data type.'###'This means that there are an indeterminable amount of parameters, and they could be any data type. You need to seriously reconsider your set up. There also seem to now be no relationship between Ids. UnlessSelect * from Employee where Name like '%###%'will be replaced toSelect * from Employee where Name like '%44%'(what employee would have a name with digits in..?)? If so, what is the string value for Id 4?StructureStringsrelate to Ids1and2inNumberStructureValues? Why does Id 3 inStructureStringsrelate to Ids4and then2(in THAT order...?) in the tableTextStructureValues. How does 3 become 4 and then 2..? There is NO relationship here. Your data needs a to be able to relate to get the answer you want. if you can't relate the data, the task is impossible.