Split Function in Sql stored procedure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Soniad
    New Member
    • Jan 2009
    • 66

    Split Function in Sql stored procedure

    Hello,

    I am new to stored procedure, i am passing one parameter to stored procedure (comma seperated). i want to know how to split this variable inside stored procedure.

    Code:
    Sample :
    
    Exec mystoreproc  '1,2,3,4,5'
    i want to split '1,2,3,4,5' in commas and to loop through these numbers.
    how to do..???

    Regards,
    "D"
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Depends on what you're going to do with it. What do you have so far?


    -- CK

    Comment

    • Soniad
      New Member
      • Jan 2009
      • 66

      #3
      Split Function in Sql stored procedure

      Originally posted by ck9663
      Depends on what you're going to do with it. What do you have so far?


      -- CK
      I want to split these numbers (1,2,3,4,5) and want to insert this id one by one in a table. if it was in vbscript or javascript i wud have done it..but don't have any idea how to do in stored procedure..the only idea i have is that by using CHARINDEX it cud be done.but how??
      any suggestion please..


      Regards,
      "D"

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        Use this technique.


        -- CK

        Comment

        • Soniad
          New Member
          • Jan 2009
          • 66

          #5
          Split Function in Sql stored procedure

          Originally posted by ck9663
          Use this technique.


          -- CK
          Thanks for ur assistance.

          Regards,

          "D"

          Comment

          Working...