November 17, 2010 at 7:53 am
I have a problem when I try to convert a query from Access to SQL Server
This is the SQL from MSAccess:
SELECT [employee].employee_id AS a, [a]+1 AS Expr1
FROM [dbo.employee];
When running the same syntax in query analyzer a get an error: Invalid column name 'a'.
Anyone?
Rono
November 17, 2010 at 8:15 am
SELECT [employee].employee_id AS a, [employee].employee_id +1 AS Expr1
FROM [dbo.employee];
or you could
select a, a+1 as Expr1
from (
SELECT [employee].employee_id AS a
FROM [dbo.employee];
) t
or maybe
;with cte
as
(SELECT [employee].employee_id AS a
FROM [dbo.employee]
)
select a, a+1 as Expr1
from cte;
Cursors never.
DTS - only when needed and never to control.
November 17, 2010 at 12:22 pm
OK, Thanks old hand.
My query example is very simplyfied. In my query I have multiple Case statements, and I want to use the results in these statements in an equation.
Is this possible in Sql server? I know it is in Access...
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply