variable return from Select

  • Hi All.

    A very simple question from a problem that i don't know how to deal with.

    I have a table named Parameters with the following fields:

    PanameterName (varchar(50) PK)

    Parametervalue (varchar(50))

    Let's say that i have 2 records on the Table

    AlarmLevel0;125

    AlarmLevel1;300

    I have a storedprocedure that uses 'built in' those values 123 and 125.

    They are used on a Date add function inside a case:

    WHEN (Monitor_Hosts.LastUpdate < DATEADD(n, -125, GetDate())) THEN 0

    What I would like to have it would be something like

    -- i know that is not correct

    @MyValue=SELECT ParameterValue FROM PARAMETERS WHERE ParameterName='AlarmLevel0'

    and the dateadd would be like

    DATEADD(n, @MyValue, GetDate())

    Any guidelines on this would be appreciated

    Thanks

    Paulo

  • The format is:

    SELECT @MyValue= ParameterValue FROM PARAMETERS WHERE ParameterName='AlarmLevel0'

    That will assign the value from the table.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Thanks

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply