~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: I have a stored procedure which accepts a parameter for the column name.
: ie Create Proc sp_addtoleaderboard @round int, @score int
:
: The sp updates a record in the leaderboard table and adds the score
: (@score) to the specified round (@round) depending upon what round it is
: (eg round 1, 2, 3, 4 etc).
:
: So to update the record i figured (excuse the coding as Ive just included
: the important bits):
: UPDATE leaderboard SET (@round) VALUES (@score)
:
: However 'SET @round' is obviously tryign to set the actual variable value
: to the score rather than the field that the variable is referring to.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Build a string in your proc, and then Exec() it:
Create sp_TestProc as
@round varchar(x),
@score varchar(x)
AS
Declare @strSQL varchar(100)
@strSQL = "UPDATE leaderboard SET (' + @round + ') VALUES (' @score ')'
Exec(@strSQL)
HTH
Cheers
Ken