Using Created Fields in Stored Procedures

  • 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!

  • Please, post the entire query.

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

    E.g.:

    selectC = derived_table_B.B + derived_table_B.A

    from(

    selectB = derived_table_A.A + 1

    ,derived_table_A.A as A

    from(

    selectA = 2 + 3

    ) derived_table_A

    ) derived_table_B

    ML

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

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply