Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 Invalid column name!

Author  Topic 

sky1224
Starting Member

12 Posts

Posted - 2009-12-17 : 03:09:59
Good Afternoon.

I made the following SQL query.(SQL Server2005)

select fld1, floor(fld2) As [7???],-- [] must be for Unicode object name
floor(fld3) As [8???],
[7???]+[8???] As [??????] -- to get sum-column of 2 columns
from tbl

But query doen't run!
Invalid column name '7???'

what's wrong with this query? I don't know.
Help me, please... Thank you.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-12-17 : 03:16:53
you cannot use the column alias within the same level of query. Use the base column name instead


select fld1, floor(fld2) As [7???],-- [] must be for Unicode object name
floor(fld3) As [8???],
floor(fld2) + floor(fld3) As [??????] -- to get sum-column of 2 columns
from tbl


or used a derived table

select fld1,
[7???],
[8???],
[7???]+[8???] As [??????] -- to get sum-column of 2 columns
from
(
select fld1,
floor(fld2) As [7???],-- [] must be for Unicode object name
floor(fld3) As [8???]
from tbl
) As d



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

sky1224
Starting Member

12 Posts

Posted - 2009-12-17 : 03:20:50
Thank you for your help.

but now I'm converting MS Access query to SQL Server Query. Such query is running in MS Access!

Is this correct?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-17 : 03:31:38
quote:
Originally posted by sky1224

Thank you for your help.

but now I'm converting MS Access query to SQL Server Query. Such query is running in MS Access!

Is this correct?


The query that works in ACCESS may not work in SQL Server

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sky1224
Starting Member

12 Posts

Posted - 2009-12-17 : 03:34:11
OK. Thank you for your help!!!
Go to Top of Page
   

- Advertisement -