[font="Verdana"]You have to use Dynamic SQL in SProc, shown below
Create Proc dbo.usp_Update
(
@table VarChar(25)
,@param1 VarChar(25)
,@param2 VarChar(25)
)
As
Begin
Begin Tran
Declare @strSQL VarChar(MAX)
Set @strSQL = 'Update ' + @table + ' Set Col1 = ' + @param1
+ ' And Col2 = ' + @param2
-- Print @strSQL
sp_ExecuteSQL(@strSQL)
If @@Error = 0
Begin
Commit Tran
End
Else
Begin
Rollback Tran
End
End
Go
One more thing, first print the variable and parse to confirm whether the build statement is syntactically proper.
Mahesh[/font]