Groups | Blog | Home
all groups > sql server data mining > january 2004 >

sql server data mining : TSQL -- function like javascript "eval" ?


Richard Morey
1/20/2004 5:24:35 PM
Hi..

I have a row in a table with 4 fields, for arguments sake, "FIELD1",
"FIELD2", "FIELD3", and "FIELD4"

I am working on a stored procedure and what I have so far is something like
this..

declare @x as int
declare @fieldName as char(6)
declare @field1value as int
declare @field2value as int
declare @field3value as int
declare @field4value as int

SELECT @field1value = FIELD1, @field2value = FIELD2, @field3value = FIELD3,
@field4value = FIELD4 from MyTable

SET @fieldName = 'FIELD' + CONVERT(char,@x)+'VALUE'




So now @fieldName = "FIELD1VALUE" is there some way I can access the value
in "field1value" through the "@fieldName" variable?

In javascript I could do value = eval(fieldName) and that would work..

I am doing some operations and the field (1, 2, 3, 4) that I want to pull
data from varies for each line.. so I'm looking for some way to do this
dynamically..

Thanks,

Rich





MACK
1/27/2004 2:41:06 PM
I haven't found an 'eval' type of function, though I know what you mean by it. In this case i'll usually create a sql strin
AddThis Social Bookmark Button