We help IT Professionals succeed at work.
Get Started

Copy Alias to Output Parameter

383 Views
Last Modified: 2012-05-09
I feel like this is a simple question but I dont have the knowledge of SQL to answer it so I figured I would let you guys take a look at it.  I have a SP that contains and output parameter named "@gas1".  I also have a select statement that does some calculations and assigns the result to an alias, "gas1".  How do I copy the result from the alias, "gas1", to the output parameter, "@gas1"???
ALTER PROCEDURE [dbo].[Urea_PressFactors_Interp] 
	-- Add the parameters for the stored procedure here
	@InputPress float = 0,
	@gas1 float output,
	@liq1 float output
	

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
SELECT ((@Inputpress - derivedtbl_1.psi1) / (derivedtbl_2.psi2 - derivedtbl_1.psi1)) * (derivedtbl_2.gas2 - derivedtbl_1.gas1) + derivedtbl_1.gas1 AS gas1
	FROM   (SELECT     PSI AS psi1, GAS AS gas1
	FROM          Urea_SC_PressFactors_3_4Spheres
	WHERE      (PSI = (SELECT MAX(PSI) AS Expr1
	FROM          Urea_SC_PressFactors_3_4Spheres AS Urea_SC_PressFactors_3_4Spheres_3
	WHERE      (PSI <= @InputPress)))) AS derivedtbl_1 CROSS JOIN
	(SELECT     PSI AS psi2, GAS AS gas2
	FROM          Urea_SC_PressFactors_3_4Spheres AS Urea_SC_PressFactors_3_4Spheres_2
	WHERE      (PSI =(SELECT MIN(PSI) AS Expr1
	FROM          Urea_SC_PressFactors_3_4Spheres AS Urea_SC_PressFactors_3_4Spheres_1
	WHERE      (PSI >= @Inputpress)))) AS derivedtbl_2

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE