You can try this also.....
CREATE PROCEDURE [dbo].[SaveSingleColumnValueFromGrid]
(
@TableName VARCHAR(200),
@ColumnName VARCHAR (200),
@CompareField VARCHAR(200),
@CompareValue VARCHAR(200),
@NewValue VARCHAR(200),
@Result INT OUTPUT
)
AS
BEGIN
DECLARE @SqlString NVARCHAR(2000),
@id INTEGER = 0;
IF @CompareValue = ''
BEGIN
SET @SqlString = 'INSERT INTO ' + @TableName + ' ( ' + @ColumnName + ' ) VALUES ( ''' + @NewValue + ''' ) ; SELECT @id = SCOPE_IDENTITY()';
EXECUTE sp_executesql @SqlString, N'@id INTEGER OUTPUT', @id OUTPUT
END
ELSE
BEGIN
SET @SqlString = 'UPDATE ' + @TableName + ' SET ' + @ColumnName + ' = ''' + @NewValue + ''' WHERE ' + @CompareField + ' = ''' + @CompareValue + '''';
EXECUTE sp_executesql @SqlString
set @id = @@ROWCOUNT
END
SELECT @Result = @id
END