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. Return Results of a Join Using Stored Proc

Return Results of a Join Using Stored Proc

Scheduled Pinned Locked Moved Database
database
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.
  • A Offline
    A Offline
    ASPnoob
    wrote on last edited by
    #1

    Hi all, I am trying to display the results of a left outer join between two tables on my web app but there seems to be problems with my stored procedure. I have tried to put the results of the left outer join into a new table by using the following stored procedure:

    USE [Payable]

    CREATE PROCEDURE [dbo].[getEmployeeData]
    AS
    BEGIN
    SELECT *
    INTO NewTable
    FROM Employees
    LEFT OUTER JOIN Hourly_Employees
    ON Employees.Employee_ID_PK = Hourly_Employees.Hourly_Employee_ID
    END

    Please point out why it does not work, thanks in advance.

    B M J 3 Replies Last reply
    0
    • A ASPnoob

      Hi all, I am trying to display the results of a left outer join between two tables on my web app but there seems to be problems with my stored procedure. I have tried to put the results of the left outer join into a new table by using the following stored procedure:

      USE [Payable]

      CREATE PROCEDURE [dbo].[getEmployeeData]
      AS
      BEGIN
      SELECT *
      INTO NewTable
      FROM Employees
      LEFT OUTER JOIN Hourly_Employees
      ON Employees.Employee_ID_PK = Hourly_Employees.Hourly_Employee_ID
      END

      Please point out why it does not work, thanks in advance.

      B Offline
      B Offline
      Boipelo
      wrote on last edited by
      #2

      What results are you expecting? What happen when you run the select statement on SQL Studio? If it were me, I will remove "INTO NewTable" statement, I assume the control on your web app will accept a DataDable or DataSet. - If Employee_ID_PK and Hourly_Employee_ID are both Employee IDs and have correct DataTypes, then I see nothing wrong with the Stored Procedure. Run it on the SQL Studio and fix any error

      I remain joe!

      1 Reply Last reply
      0
      • A ASPnoob

        Hi all, I am trying to display the results of a left outer join between two tables on my web app but there seems to be problems with my stored procedure. I have tried to put the results of the left outer join into a new table by using the following stored procedure:

        USE [Payable]

        CREATE PROCEDURE [dbo].[getEmployeeData]
        AS
        BEGIN
        SELECT *
        INTO NewTable
        FROM Employees
        LEFT OUTER JOIN Hourly_Employees
        ON Employees.Employee_ID_PK = Hourly_Employees.Hourly_Employee_ID
        END

        Please point out why it does not work, thanks in advance.

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Assuming SQL Server Take the select statement out of your proc into SSMS and confirm that your query returns results! Why are you inserting the results into another table in the database when you want the results in your client. Remove the INTO NewTable and the results will be returned to your calling command. Explicitly return the columns you want rather than *.

        Never underestimate the power of human stupidity RAH

        1 Reply Last reply
        0
        • A ASPnoob

          Hi all, I am trying to display the results of a left outer join between two tables on my web app but there seems to be problems with my stored procedure. I have tried to put the results of the left outer join into a new table by using the following stored procedure:

          USE [Payable]

          CREATE PROCEDURE [dbo].[getEmployeeData]
          AS
          BEGIN
          SELECT *
          INTO NewTable
          FROM Employees
          LEFT OUTER JOIN Hourly_Employees
          ON Employees.Employee_ID_PK = Hourly_Employees.Hourly_Employee_ID
          END

          Please point out why it does not work, thanks in advance.

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          ASPnoob wrote:

          Please point out why it does not work

          Because you are putting it into a table instead of returning it.

          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