Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Using Created Fields in Stored Procedures Expand / Collapse
Posted Wednesday, July 30, 2008 9:04 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, July 15, 2009 8:43 AM
Points: 25, Visits: 55
I'm sure my terminalogy is incorrect, but I will attempt to explain: I have an Access front-end with an SQL Database backend. In Access I created a Stored Procedure using fields from the Datbase Tables. I then needed to create a Field using a formula : [PD Time]/86400 , and entered an Alias as PDT.. Everything works. Then I want to use the PDT for another created field;
CASE WHERE [PDT]>#12:15# THEN 'No' ELSE 'Yes' END with the Alias as PDA. This fails with the inability to find PDT? I'm also sure that the reference to time #12:15# is in error also, but I have to take things one at a time. You use # sign for time in Access.

First of all how do you reference a created field which has been created prior to the use of it in another created field?


PS: Just thinking do I first need to create the fields in the Table? Plus how do you create a stored Procedure from another Stored Procedure? I have a lot to learn and little time, they want to comvert to my new ADP soon!
Post #543585
Posted Thursday, August 28, 2008 6:01 AM


Group: General Forum Members
Last Login: Wednesday, January 27, 2016 3:30 AM
Points: 2,871, Visits: 379
Please, post the entire query.

From what I could understand from your post you could use a subquery or a derived table.

select	C = derived_table_B.B + derived_table_B.A
from (
select B = derived_table_A.A + 1
,derived_table_A.A as A
from (
select A = 2 + 3
) derived_table_A
) derived_table_B


Matija Lah, SQL Server MVP
Post #560318
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse