General discussion

  • Creator
    Topic
  • #2131101

    Processing parameters in TransAct SQL

    Locked

    by dmitryzb. ·

    Here’s my problem:

    select *
    from #my_vars
    where sec_type in (select @new_type)

    Variable @new_type contains different values (Ex. string1, string2, or “string1″,”string2″) to match one or the other or both. When the var contains string1 or string2, it works. When it contains the combo (this is how I assign the value)

    select @new_type = ‘”string1”,”string2″‘

    it doesn’t work.

    If I hard code the combo in the where clause, like this:

    where sec_type in (“string1″,”string2”)

    it works.

    Maybe it’s the version of Sybase that I’m running?..

    Thank you,
    – Dmitry

All Comments

  • Author
    Replies
    • #3569144

      Processing parameters in TransAct SQL

      by agibbs ·

      In reply to Processing parameters in TransAct SQL

      I’ve never used Sybase, but in MS SQL (and according the T-SQL standard) that just won’t work the way you’re doing it . . .

      You’ll have to store the values for @new_type in a table, and use a statement more like this:

      SELECT * FROM #my_vars
      WHERE sec_type IN (SELECT new_type FROM table_1)

      Best,
      Aaron

      • #3425829

        Processing parameters in TransAct SQL

        by dmitryzb. ·

        In reply to Processing parameters in TransAct SQL

        Aaron,

        Thank you for your help. That’s actually what I had in mind, but was hoping I didn’t have to do that.

        Sorry for the delay, I was just waiting to see if I get any other responses. Thanks again,

        – Dmitry

    • #3425828

      Processing parameters in TransAct SQL

      by dmitryzb. ·

      In reply to Processing parameters in TransAct SQL

      This question was closed by the author

Viewing 1 reply thread