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
 Transact-SQL (2005)
 Is the grammar correct?

Author  Topic 

zhshqzyc
Posting Yak Master

240 Posts

Posted - 2008-07-29 : 12:07:10
a query just as

select 676 as x

The query with "from tablename"
I don't know if it is okay or not.

Thanks

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-07-29 : 12:21:18
Did you try running it in the query analyzer? Also, look at Books On Line under select clause

Jim
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-29 : 12:56:21
quote:
Originally posted by zhshqzyc

a query just as

select 676 as x

The query with "from tablename"
I don't know if it is okay or not.

Thanks


why do you want from tablename here. you're just using a constant name so dont need a table name to refer to
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2008-07-29 : 13:18:43
That's a column alias, not a table alias. Maybe he wants the value to show up with a label.

e4 d5 xd5 Nf6
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-29 : 13:33:49
quote:
Originally posted by blindman

That's a column alias, not a table alias. Maybe he wants the value to show up with a label.

e4 d5 xd5 Nf6


nope i was referring to this part

The query with "from tablename"
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2008-07-29 : 13:37:06
Then I'm with you. I don't know what the heck he is talking about.

e4 d5 xd5 Nf6
Go to Top of Page

zhshqzyc
Posting Yak Master

240 Posts

Posted - 2008-07-29 : 13:59:51
Yeah. I want the value to show up with a label
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-07-29 : 15:19:19
Hi,
you can do
select 676 as x
in a query-window and your result is 676 with label x

You can do also

select
676 as x,
your_id,
your_name
from your_table where ...

and your result (depending on contents of your_table) will have various ids and names and always x as first column with its value 676.

Greetings
Webfred

There are 10 types of people in the world: Those who understand binary, and those who don't...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-30 : 03:55:26
quote:
Originally posted by zhshqzyc

a query just as

select 676 as x

The query with "from tablename"
I don't know if it is okay or not.

Thanks


In SQL Server, you dont need table name to select just a constant unlike you need dual table in ORACLE

Madhivanan

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

- Advertisement -