Re: SELECT 42 AS a, a AS b FROM system.iota



dtmackenzie <david.mackenzie@xxxxxxxxxxxx> wrote:
I'm wondering if a is a column of system.iota ...

David, does "select a as b from system.iota" work ?

Luc.

Luc, system.iota in ADS has only one row and one column, which is also
named "iota".
As expected "select a as b from system.iota" returns an error message
that column "a" doesn't exist.

My example is reduced to a minimum for demonstration purposes but it's
not just a theoretical problem - in the real SELECT there is a longer
expression instead of "42" which I would like to avoid repeating in
several places (which clutters up the code and hinders maintenance).

Yes, that's what I thought, but by reducing an example, it can
become unclear what you want to achieve. Your question is
kind of ambiguous : it can be interpreted as "can I give an item
in the select list the same name as the name of a column", while you
mean "can I make a reference to an item in the select list further in the
query by using the name I gave it" :-).

What you want doesn't work in ASE (spid is a columnname of sysprocesses) :

select spid as a, a as b from sysprocesses;
Msg 207, Level 16, State 4
Server 'DSP_ST_1_b', Line 1
Invalid column name 'a'.

Luc.

.



Relevant Pages

  • Re: SELECT 42 AS a, a AS b FROM system.iota
    ... What you want doesn't work in ASE (spid is a columnname of sysprocesses): ... Hello Luc, the ambiguity didn't occur to me, probably because in ADS ... select suid as spid, ...
    (comp.databases.sybase)
  • Re: Help with blocking
    ... I don't think parallel queries cause multiple rows in sysprocesses. ... see multiple entries in sysprocesses related to same SPID when lightweight ... > same SPID with different values in the ecid column for each process. ...
    (microsoft.public.sqlserver.server)
  • sysprocesses table in Master db
    ... There is a column named "nt_username" in sysprocesses ... tells me the exact nt login name, ... what "spid" tells. ... Jeanny ...
    (microsoft.public.sqlserver.programming)
  • Re: Allowing only certain clients access to SQL Server 2K
    ... > select net_address from sysprocesses where spid = @spid ... >>I want to increase security on my SQL Server database by restricting ...
    (microsoft.public.sqlserver.security)
  • Re: How to translate net_address
    ... select spid, dbo.fn_getIPaddress(hostname) as IPaddress ... from sysprocesses ... Please reply only to the newsgroups. ...
    (microsoft.public.sqlserver.connect)