declare @updatedef table ( id int identity, tablename varchar(30), columnname varchar(50), Status_fl bit)
declare @max-2 int ,@cnt int ,@lstr varchar(200),@tablename varchar(30),@columnname varchar(50)
set nocount on
insert into @updatedef (tablename,columnname,Status_fl )
select 'emp', 'fname',1 union
select 'emp', 'age',1 union
select 'emp', 'Phone' ,1 union
select 'EmpSalary', 'Salary' ,1
select @max-2 = MAX(id) from @updatedef
set @cnt = 1
while (@cnt < = @max-2)
begin
select @lstr = '',@tablename = '',@columnname = ''
select @columnname = columnname, @tablename = tablename from @updatedef
where id = @cnt and Status_fl = 1
set @lstr = 'UPDATE dbo.' + @tablename + ' SET ' + @columnname + ' = REPLACE(' + @columnname + ' ''S'', ''t'')'
print @lstr
set @cnt = @cnt + 1
end
BUT above code ..need CASE statement too to decide which columns need what kind of replace text.
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)