soozh
asked on
query syntax
This is a simple question and i just need a bit of advise.
I have to produce the nvarchar(max) variable @series. See below.
Currently the value "data" is set to zero for each object in the series.
The values for each object is held in a table whose columns are named: Series1, Series2, Series3 etc. (there are 12).
What would be the best way to populate @series using a select statement given that i know the id value of the record i am interested in.
i.e.
Should i use a variables and a select statement along the lines
select @series1=series1, @series2=series2 ect..
and then build @series by using something like i show below, or is there a more elegant solution?
I have to produce the nvarchar(max) variable @series. See below.
set @series = '<series>[
{name: "Vanföreställningar", data: [0], color: "STEELBLUE"},
{name: "Hallucinationer", data: [0], color: "FIREBRICK"},
{name: "Agitation/aggressivitet",data: [0], color: "GOLD"},
{name: "Depression/dysfori", data: [0], color: "LIGHTBLUE"},
{name: "Ångest", data: [0], color: "INDIANRED"},
{name: "Eufori/upprymdhet", data: [0], color: "DIMGREY"},
{name: "Apati/likgiltighet", data: [0], color: "MEDIUMBLUE"},
{name: "Hämningslöshet", data: [0], color: "POWDERBLUE"},
{name: "Irritabilitet/labilitet", data: [0], color: "GREY"},
{name: "Motorisk av. beteende",data: [0], color: "MEDIUMVIOLETRED"},
{name: "Sömn", data: [0], color: "GREEN"},
{name: "Aptit/ätstörningar", data: [0], color: "SKYBLUE"}
]</series>'
Currently the value "data" is set to zero for each object in the series.
The values for each object is held in a table whose columns are named: Series1, Series2, Series3 etc. (there are 12).
What would be the best way to populate @series using a select statement given that i know the id value of the record i am interested in.
i.e.
select series1, series2, series3 ... from MyTable where id = 12
Should i use a variables and a select statement along the lines
select @series1=series1, @series2=series2 ect..
and then build @series by using something like i show below, or is there a more elegant solution?
set @series = '<series>[
{name: "Vanföreställningar", data: [' + @series1 +'], color: "STEELBLUE"},
{name: "Hallucinationer", data: [' + @series2 + '], color: "FIREBRICK"},
etc
]</series>'
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER