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.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-07-11 : 22:40:02
|
Vishnu writes "I have a table named MYTABLE containing FIELD1 which has 3 sample records.Vi$$$uSam'leTestI want to execute a stored procedure that will accept two parameters. First parameter to search and second parameter to replace.If i execute the stored procedure as follows,exec Myprocedure "$'" "Kp" then my expected result should be like ViKKKuSampleTestIf i use the following codecreate procedure proc1(@find varchar(6),@replace varchar(6))asdeclare @slen int,@currpos intdeclare @repchar char(1)select @currpos=1select @slen= datalength(@find)while @currpos <= @slenbegin select @repchar = substring(@replace,@currpos,1) update mytable set field1 = isnull(stuff(field1,charindex(substring(@find,@currpos,1),field1),1,substring(@replace,@currpos,1)),field1) select @currpos=@currpos + 1endam getting the following result.ViK$$uSampleTestCan you help me to solve this????Thanks" |
|
|
|
|
|
|