Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Decmposition of the text inside a store procedure

Author  Topic 

sarfrazabdu
Starting Member

5 Posts

Posted - 2014-01-22 : 11:37:33
I have a stored procedure (This SP is used to replace a n existing content with a new conetnt by searching for that content in a big text document ). The new conetnt and existing conetnt 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?

sarfraz

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-01-23 : 07:10:45
duplicate of
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=190848
please dont cross post

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -