Dear,
This procedure only works for 'char', 'varchar', 'nchar', 'nvarchar' Datatypes.
In This Procedure you can replace Any Fields of above datatypes cell values of any of the table
of your current database.
Try to check below example
Where I create one table with 2varchar fields And one Autogenerated primary key.
Then i passed value of last cell 'Ajeet' And new value 'Ajit' So procedure itself search the value And Replace by your second
Value.
i.e. 'Ajeet' Replaced by 'Ajit'
-- Create Table
CREATE TABLE [dbo].[TblUsers](
[UId] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[UName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Pwd] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
) ON [PRIMARY]
GO
-- Insert Values
INSERT INTO [dbo].[TblUsers] ([UName],[Pwd]) VALUES('Tedulkar','Sachin')
INSERT INTO [dbo].[TblUsers] ([UName],[Pwd]) VALUES('Sewag','Virendra')
INSERT INTO [dbo].[TblUsers] ([UName],[Pwd]) VALUES('Ganguli','Saurav')
INSERT INTO [dbo].[TblUsers] ([UName],[Pwd]) VALUES('Dhoni','Mahi')
INSERT INTO [dbo].[TblUsers] ([UName],[Pwd]) VALUES('Agarkar','Ajeet')
GO
-- Check Records
Select * From TblUsers
GO
-- Execute Procedure
Exec SearchAndReplace @SearchStr = 'Ajeet', @ReplaceStr = 'Ajit'
GO
-- Again Check Records To see Updation
Select * From TblUsers
Try it and let me know if you want to understand more.
Its great logical thing to change same Records of whole database at once execution.