Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Referencing the results of a stored procedure from a stored procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-07-09 : 00:58:22
Heidi writes "I have a stored procedure that references the results of another stored procedure. Access allows you to add a query and table to the query designer, how does this work with SQL Server2000? For example, In access, I have created the first query using a table. In this query, I concatenate 3 fields to create the field Hire Date. In the second query I reference the results of the first query. In other words, I reference Query1.Hire Date.

How does this work with SQL? Here is stored procedures that I have created in SQL 2000. When I try to run the second procedure, it cannot find the 1st stored procedure.

Thanks for your help - :-)
QUERY 1
CREATE PROCEDURE qryEmployeeList
AS
SELECT [EHOSP#] AS HospNum, ENUM, RTrim([ELNAME]) + ', ' + RTrim([EFNAME]) + ' ' + RTrim([EINIT]) AS EmpName, RTrim([EADDR1]) + ' ' + RTrim([EADDR2]) AS Address,
RTrim([ECITY]) + ', ' + [ESTATE] + ' ' + RTrim([EZIP]) AS Address2,
'(' + Convert(nvarchar,[EPHACD]) + ') ' + Left([EPHONE],3) + '-' + Left([EPHONE],4) AS Phone,
Birthdate =
CASE
WHEN EDOBY = 0 THEN Null
Else CONVERT(Datetime,Convert(nvarchar,[EDOBm]) + '/' + Convert(nvarchar,[EDOBd])
+ '/' + CONVERT(nvarchar,[EDOBy]))
END,
ESSNUM, ESEX, EMARST, EDEPT, EDNAME, EBUDHR,[EGL#], ESHIFT, ECHDTM, ECHDTD,
MDCurHireDt =
CASE
WHEN ECHDTY = 0 THEN NULL
ELSE CONVERT(nvarchar,[ECHDTm]) + '/' + CONVERT(nvarchar,[ECHDTd])
End,
CurHireDt =
CASE
WHEN ECHDTY = 0 THEN Null
ELSE CONVERT(Datetime, CONVERT(nvarchar,[ECHDTm]) + '/' + CONVERT(nvarchar,[ECHDTd])
+ '/' + CONVERT(nvarchar,[ECHDTy]))
END,
EXMPT,
[LOA-Dt] =
CASE
WHEN ELOAy = 0 THEN Null
ELSE CONVERT(DateTime, CONVERT(nvarchar,[ELOAm]) + '/' + CONVERT(nvarchar,[ELOAd])
+ '/'+ CONVERT(nvarchar,[ELOAy]))
END,
ELOARS,
LOARtnDt =
CASE
WHEN ELOAry = 0 THEN NULL
ELSE CONVERT(Datetime, CONVERT(nvarchar,[ELOArm]) + '/' + CONVERT(nvarchar,[ELOArd])
+ '/' + CONVERT(nvarchar,[ELOAry]))
END,
ELTSB AS LongTermSickLeave, EAPLB AS PaidLeave,
SalaryReviewDate =
CASE
WHEN ESALRY = 0 THEN NuLL
ELSE CONVERT(DateTime,CONVERT(nvarchar,[ESALRM]) + '/' + CONVERT(nvarchar,[ESALRD])
+ '/' + CONVERT(nvarchar,[ESALRY]))
END,
BenAccrualDt =
CASE
WHEN EOHDTy = 0 THEN NULL
ELSE CONVERT(Datetime, CONVERT(nvarchar,[EOHDTm]) + '/' + CONVERT(nvarchar,[EOHDTd])
+ '/' + CONVERT(nvarchar,[EOHDTy]))
END,
EJOBCD, EJDSRC, EPGRAD, ESTEP, ELEVEL, ERATE, EMIN, EMAX, EOOHRM, EOOHRD,
PerRvwCmpDt =
CASE
WHEN EPFMRy = 0 THEN NULL
ELSE CONVERT(Datetime, CONVERT(nvarchar,[EPFMRm]) + '/' + CONVERT(nvarchar,[EPFMRd])
+ '/' + CONVERT(nvarchar,[EPFMRy]))
END,
MDPerRvwDueDt =
CASE
WHEN EOOHRY = 0 THEN NULL
ELSE CONVERT(nvarchar,[EOOHRM]) + '/' + CONVERT(nvarchar,[EOOHRD])
END,
PerRvwDueDt =
CASE
WHEN EOOHRY = 0 THEN NULL
ELSE CONVERT(Datetime,CONVERT(nvarchar,[EOOHRM]) + '/' + CONVERT(nvarchar,[EOOHRD])
+ '/' + CONVERT(nvarchar,[EOOHRY]))
END
FROM [PP#FILE_PPPEMPM]
WHERE (ESTAT='A') AND (EXCNT= 0)
ORDER BY RTrim([ELNAME]) + ', ' + RTrim([EFNAME]) + ' ' + RTrim([EINIT]);
GO


Query 2
CREATE PROCEDURE ActiveState @inflateSize int AS

SELECT qryEmployeeList.HospNum, qryEmployeeList.ENUM, qryEmployeeList.EmpName, qryEmployeeList.EDEPT, qryEmployeeList.EDNAME,
LOADays =
CASE
WHEN LOARtnDt = Null Then DATEDIFF(day,[Loa-dt],getDate())
ELSE DATEDIFF(day,[Loa-dt],LOARtnDt)
END,
qryEmployeeList.[LOA-Dt], qryEmployeeList.LOARtnDt, qryEmployeeList.ELOARS, qryEmployeeList.PerRvwCmpDt,
qryEmployeeList.PerRvwDueDt, qryEmployeeList.CurHireDt, [WB#MGR_HOSP].EvalPreDueDys,
PreDueDate =
CASE
WHEN PerRvwDueDt = CurHireDt THEN CurHireDt + EvalNewHireDys - EvalPr
   

- Advertisement -