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. Doubt in Stored procedure

Doubt in Stored procedure

Scheduled Pinned Locked Moved Database
databasehelp
4 Posts 4 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.
  • P Offline
    P Offline
    Prashant C
    wrote on last edited by
    #1

    I written strored procedure as below create procedure testProc @param varchar(100) as select * from authors where au_id in (@param) when i, execute this with following parameters, it gives me error. I execute it like this.. exec testProc('''2104206'',''123''') Regards PVC :sigh:

    N 1 Reply Last reply
    0
    • P Prashant C

      I written strored procedure as below create procedure testProc @param varchar(100) as select * from authors where au_id in (@param) when i, execute this with following parameters, it gives me error. I execute it like this.. exec testProc('''2104206'',''123''') Regards PVC :sigh:

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      parasu_516 wrote:

      exec testProc('''2104206'',''123''')

      Change this to exec testProc('2104206','123') How can you pass two values to procedure when the procedure accepts only one ?:confused: http://w3hearts.com/articles/6/[^]


      printf("Navaneeth!!") www.w3hearts.com

      M 1 Reply Last reply
      0
      • N N a v a n e e t h

        parasu_516 wrote:

        exec testProc('''2104206'',''123''')

        Change this to exec testProc('2104206','123') How can you pass two values to procedure when the procedure accepts only one ?:confused: http://w3hearts.com/articles/6/[^]


        printf("Navaneeth!!") www.w3hearts.com

        M Offline
        M Offline
        Mark Greenwood
        wrote on last edited by
        #3

        Actually you need to change it to be exec testProc('2104206,123') If you look at what the SP is trying to do he wants to be able to pass in a range of values and return those details which are in the LIST of items as a single parametr. Now I'm not even going to get started on WHY this is dangerous for security - but this will make it work...... Mark.

        M 1 Reply Last reply
        0
        • M Mark Greenwood

          Actually you need to change it to be exec testProc('2104206,123') If you look at what the SP is trying to do he wants to be able to pass in a range of values and return those details which are in the LIST of items as a single parametr. Now I'm not even going to get started on WHY this is dangerous for security - but this will make it work...... Mark.

          M Offline
          M Offline
          M H 1 2 3
          wrote on last edited by
          #4

          Correct me if I am wrong but wont't the in operator have problems with a varchar string that happens to have commas? http://www.projectdmx.com/tsql/sqlarrays.aspx You might also want to consider dynamic sql. I have a feeling that on a lot of records you could get better performance.

          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