SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Using Created Fields in Stored Procedures


Using Created Fields in Stored Procedures

Author
Message
pete.trudell
pete.trudell
Valued Member
Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)

Group: General Forum Members
Points: 51 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?

Thanks

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!
Matija Lah
Matija Lah
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3069 Visits: 380
Please, post the entire query.

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

E.g.:

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



ML

---
Matija Lah, SQL Server MVP
http://milambda.blogspot.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search