Passing Multiple values in stored procedure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muhammadrashidmughal
    New Member
    • Feb 2008
    • 13

    Passing Multiple values in stored procedure

    I need to know a way to pipe the output of an sql (select )statement to a stored procedure.
    Eg:
    The stored procedure is sp_rsch_filters param1,param2,p aram3

    Requirement is to pass param1,param2 and param3 from user X.
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    Sorry I am confused
    You begin by asking
    I need to know a way to pipe the output of an sql (select )statement to a stored procedure.

    and finish with
    Requirement is to pass param1,param2 and param3 from user X.

    can you clarify the question for me please?
    do you want to pass a recordset or parameters?

    Comment

    • muhammadrashidmughal
      New Member
      • Feb 2008
      • 13

      #3
      Originally posted by Delerna
      Sorry I am confused
      You begin by asking
      I need to know a way to pipe the output of an sql (select )statement to a stored procedure.

      and finish with
      Requirement is to pass param1,param2 and param3 from user X.

      can you clarify the question for me please?
      do you want to pass a recordset or parameters?
      --------------------------------------------------------------------------------------------------------------------well

      i want to create a stored procedure in which i pass more than one values in one
      variable

      Comment

      • Delerna
        Recognized Expert Top Contributor
        • Jan 2008
        • 1134

        #4
        do you mean like this
        Code:
        exec prMyProc 'val1,val2,val3,val4'
        where the procedure is
        Code:
        CREATE PROC prMyProc @PramVar varchar(1000)
        AS
        --code to extract the values from @PramVar
        GO

        Comment

        • muhammadrashidmughal
          New Member
          • Feb 2008
          • 13

          #5
          Originally posted by Delerna
          do you mean like this
          Code:
          exec prMyProc 'val1,val2,val3,val4'
          where the procedure is
          Code:
          CREATE PROC prMyProc @PramVar varchar(1000)
          AS
          --code to extract the values from @PramVar
          GO
          -------------------------------------------------------------------------------------------------------
          yes i need this

          Kindly send me complete code

          thanx

          please send me complete o

          Comment

          • Delerna
            Recognized Expert Top Contributor
            • Jan 2008
            • 1134

            #6
            Code:
            exec prMyProc 'val1,val2,val3,val4'
            where the procedure is

            Code:
            CREATE PROC prMyProc @PramVar varchar(1000)
            AS
               declare @V1 varchar(10), @V2 varchar(10), @V3 varchar(10), @V4 varchar(10)
            set @V1= left(@Param,charindex(',',@Param)-1)
            set @Param= right(@Param,len(@Param)-charindex(',',@Param))
            set @V2= left(@Param,charindex(',',@Param)-1)
            set @Param= right(@Param,len(@Param)-charindex(',',@Param))
            set @V3= left(@Param,charindex(',',@Param)-1)
            set @V4= right(@Param,len(@Param)-charindex(',',@Param))
            
            --do whatener it is that you are going to do with @V1,@V2,@V3,@V4
            
            GO

            Comment

            • Delerna
              Recognized Expert Top Contributor
              • Jan 2008
              • 1134

              #7
              now that I've given you that, I have a question
              Why wouldn't you just do this

              Code:
              exec prMyProc val1,val2,val3,val4
              where the procedure is

              Code:
              CREATE PROC prMyProc @v1 varchar(10), @v2 varchar(10) @v3 varchar(10) @v4 varchar(10)
              AS
              --do whatener it is that you are going to do with @V1,@V2,@V3,@V4
              
              GO

              Comment

              Working...