I want to write a generic stored procedure in sqlserver 2000.which should update the data in uppercase..it should not hard coded as below.
Please help me in rewriting the generic code..when tablename or field passed it should update in the respective tables.
CREATE Procedure dbo.UpdateUP
@Tablename Varchar(100),
@field1 varchar(50),
@field2 varchar(50),
@field3 varchar(50),
As
IF @Tablename= 'Customer' and (@field1 is null or @field1='fname') and (@field2 is null or @field2='lname')
UPDATE [Customer]
SET [fname] = UCase([@field1])
, [lname] =UCase([@field2])
Else if @Tablename= 'City' and (@field1 is null or @field1='street') and (@field2 is null or @field2='street1') and (@field3 is null or @field3='street3')
end if
end if
Please help me in rewriting the generic code..when tablename or field passed it should update in the respective tables.
CREATE Procedure dbo.UpdateUP
@Tablename Varchar(100),
@field1 varchar(50),
@field2 varchar(50),
@field3 varchar(50),
As
IF @Tablename= 'Customer' and (@field1 is null or @field1='fname') and (@field2 is null or @field2='lname')
UPDATE [Customer]
SET [fname] = UCase([@field1])
, [lname] =UCase([@field2])
Else if @Tablename= 'City' and (@field1 is null or @field1='street') and (@field2 is null or @field2='street1') and (@field3 is null or @field3='street3')
end if
end if