Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Stored Procedure Question

Stored Procedure Question

Scheduled Pinned Locked Moved Database
databasesharepointcomgame-devhelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brent Lamborn
    wrote on last edited by
    #1

    I want to create a stored procedure where I can select with a 'where in ' and a list of integers against the integer-typed primary key. For example: PR_GetSomething @ID='0,1' Only that doesn't work since it is a varchar. Here is the ad-hoc query for what I want to do in an SP: select * from Something where ID IN (0,1) Thanks for any help....


    "Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.

    G 1 Reply Last reply
    0
    • B Brent Lamborn

      I want to create a stored procedure where I can select with a 'where in ' and a list of integers against the integer-typed primary key. For example: PR_GetSomething @ID='0,1' Only that doesn't work since it is a varchar. Here is the ad-hoc query for what I want to do in an SP: select * from Something where ID IN (0,1) Thanks for any help....


      "Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.

      G Offline
      G Offline
      gauthee
      wrote on last edited by
      #2

      When you are forming the string of ids itself try to include '' in that string. "0,1" -> "'0', '1',...."

      Gautham

      B 1 Reply Last reply
      0
      • G gauthee

        When you are forming the string of ids itself try to include '' in that string. "0,1" -> "'0', '1',...."

        Gautham

        B Offline
        B Offline
        Brent Lamborn
        wrote on last edited by
        #3

        Thanks for the response but that didn't work for me. I think it is becasuse theId param in my SP is a varchar? I dunno, maybe I should use a different datatype in that param? I get this: Conversion failed when converting the varchar value ''0','1'' to data type int.


        "Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.

        B 1 Reply Last reply
        0
        • B Brent Lamborn

          Thanks for the response but that didn't work for me. I think it is becasuse theId param in my SP is a varchar? I dunno, maybe I should use a different datatype in that param? I get this: Conversion failed when converting the varchar value ''0','1'' to data type int.


          "Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.

          B Offline
          B Offline
          Brent Lamborn
          wrote on last edited by
          #4

          Ah well...I'll just make two seperate SP's. One for a specific ID and the other for all of 'em.


          "Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups