Return Results of a Join Using Stored Proc
-
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
ENDPlease point out why it does not work, thanks in advance.
-
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
ENDPlease point out why it does not work, thanks in advance.
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!
-
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
ENDPlease point out why it does not work, thanks in advance.
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
-
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
ENDPlease point out why it does not work, thanks in advance.