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. How to use one sp's result in my new Sp

How to use one sp's result in my new Sp

Scheduled Pinned Locked Moved Database
sharepointhelptutorial
3 Posts 3 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
    pashitech
    wrote on last edited by
    #1

    Hi, I have an sp name Movie_SP which returns all the movies by taking MovieName Now in my New sp(Search_Movies_SP) I want to use the out put of the first SP(Movie_SP) and with the result of Movie_SP I have to manipulate Actually I need to set priorities as my first SP Movie_SP is returning all the movies with say BLACK in an Improper way I want to make it to a order where Black comes First, then The Movies which starts with Black second, and the third is The Movies which contains Black Plz help me thanks Pashi

    J A 2 Replies Last reply
    0
    • P pashitech

      Hi, I have an sp name Movie_SP which returns all the movies by taking MovieName Now in my New sp(Search_Movies_SP) I want to use the out put of the first SP(Movie_SP) and with the result of Movie_SP I have to manipulate Actually I need to set priorities as my first SP Movie_SP is returning all the movies with say BLACK in an Improper way I want to make it to a order where Black comes First, then The Movies which starts with Black second, and the third is The Movies which contains Black Plz help me thanks Pashi

      J Offline
      J Offline
      Joe 2
      wrote on last edited by
      #2

      Could've been better if you have mentioned which database you are working with.Assuming that you are working with Sql Server...

      pashitech wrote:

      use the out put of the first SP

      Are you looking out for something like an Output Parameter[^]? If no (which I assume so), I guess you'll have to populate the data onto a temporary table for manipulations.

      pashitech wrote:

      make it to a order

      You may try using the LIKE[^]operator.

      Select * from tblMovies where MovieName = 'Black'

      The above query fetches you details where the movie name is black (an exact match)

      Select * from tblMovies where MovieName Like 'Black%'

      The above query gives you details where the movie name begins with black (including black)

      Select * from tblMovies where MovieName like '%Black%'

      This one fetches movie names that contain the word black. -- For better usage with the like operator, refer to the URL linked.

      1 Reply Last reply
      0
      • P pashitech

        Hi, I have an sp name Movie_SP which returns all the movies by taking MovieName Now in my New sp(Search_Movies_SP) I want to use the out put of the first SP(Movie_SP) and with the result of Movie_SP I have to manipulate Actually I need to set priorities as my first SP Movie_SP is returning all the movies with say BLACK in an Improper way I want to make it to a order where Black comes First, then The Movies which starts with Black second, and the third is The Movies which contains Black Plz help me thanks Pashi

        A Offline
        A Offline
        andyharman
        wrote on last edited by
        #3

        How about:

        create table #temp1 (
          --list of columns returned by Movie_SP goes here
          )
        insert into #temp1
          exec Movie_SP @Param1, Param2, ...
        select * from #temp1
          order by case
            when Title = 'Black' then 'A'
            when Title LIKE 'Black %' then 'B'
            else 'C'
            end,
            Title
        

        You can use "insert into" to return the resultset of a stored procedure into a temporary table. The following select statement uses a case statement to prioritorise the ordering. You might need to tweak this a bit because I didn't quite understand your requirements. Regards Andy

        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