0

I have a stored procedure (This SP is used to replace a n existing content with a new content by searching for that content in a big text document ). The new content and existing content will be sent as parameters to the SP. Consider the paramaters as

@oldContent varchar(100),
@newContent varchar(100),
@WholeContent varchar(500),

Inside the stored procedure , we have a replace function , which would be called

set @ WholeContent = REPLACE(@WholeContent, @oldContent, @newContent)

and it was working fine ,

Now there is a change in the business , the trick is that we are going to have multiple old values ( which will be sent as a single parameter) The values that will be sent will be like below For example ,

oldContent = ‘sa[abc]f[wes]’
newContent =’sam’

The new content will have only 1 value say ‘sam’ , but the old content can have different values , the old value sent in this example is sa[abc]f[wes] Now we should be decompose the old content to saafw, sabfw,………..sacfs….(total 9) Then we call the function replacefunction which replaces the oldconetnt( text created by all combination) with the new one.…. So,

set @ WholeContent = REPLACE(@WholeContent, @oldContent, @newContent)

this should be called multiple times.

Just was looking how to implement this decomposition of the old values to different values and calling the replace function in a very efficient way . Is there any build in function which can decompose the same and give different combination?

  • 1
    I'm not sure I agree that this is a job for SQL Server in the first place. It's good at a lot of stuff, but without even the most primitive RegEx support out of the box, this isn't one of them. – Aaron Bertrand Jan 22 '14 at 18:51

1 Answers1

1

Unless you are doing a single Sql-Server application, witch runs exclusively in the Sql-Server environment, you should implement Regular Expression, witch is probably offered by your language/framework by some API.

Community
  • 1
  • 1