Re: Cannot Reference Named Column in WHERE Clause



Doug,

That is not defined to work in TSQL. You have not renamed the column in the
select statement, just gave the column a different header. The WHERE still
needs to be told the actual column name. I don't think that this ever
worked, but my memory of ancient days may be fading.

The ORDER BY is ordering the result set, so it can be argued that since this
step comes after the query, it now knows the result set's column name.

RLF

"Chaplain Doug" <ChaplainDoug@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0C2F8299-DA6E-4216-B628-779CD927A8A6@xxxxxxxxxxxxxxxx
SQL Server 2005.

I have a view defined for a database. Part of the query is:

SELECT dbo.GL7PROJECTS.PROJECTID AS JURISDICTION

I have not problem using JURISDICTION in the ORDER BY clause, but when I
try
to use it in a WHERE clause (e.g., WHERE JURISDICTION LIKE '001%') I get
an
error (while in the SQL Server Management Studio) saying:

Invalid column name 'JURISDICTION'

What might be causing this and why does it not work??? Thanks for the
help.

--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org


.



Relevant Pages

  • Re: Is it possible to use "all" in a paramater query
    ... Put something like this in the criteria of the query... ... > Is there anyway to have a user type in “all” in a parameter query and ... This all depends on the jurisdiction. ...
    (microsoft.public.access.queries)
  • Cannot Reference Named Column in WHERE Clause
    ... Part of the query is: ... SELECT dbo.GL7PROJECTS.PROJECTID AS JURISDICTION ... I have not problem using JURISDICTION in the ORDER BY clause, ... error (while in the SQL Server Management Studio) saying: ...
    (microsoft.public.sqlserver.mseq)