all groups > sql server programming > december 2006 >
You're in the

sql server programming

group:

Just wondering...


Just wondering... Shocky
12/16/2006 11:43:14 PM
sql server programming:
Am using SQL Server 2000.

I just came across the following.

Consider the below query

select distinct.tbl.Col1
from tab1 tbl

The above select statement works fine (Notice the dot after distinct :
DISTINCT.TBL.COL1)

However if i remove the table alias it does not work

select distinct.col1
from tab1

The above throws an error.

Does anybody have an explanation.
Re: Just wondering... Uri Dimant
12/17/2006 12:00:00 AM
Shocky

It does not work on SQL Server 2005, in my opinion it is a bug SQL Server
2000


[quoted text, click to view]

Re: Just wondering... Shocky
12/17/2006 12:27:51 AM


[quoted text, click to view]


It works fine.
it outputs the distinct values of Col1 of table tab1 just as select
distinct col1 from tab1 would do.
That's what i'm wondering..how it works

@Hari
Sir, i am aware of the T-SQL Syntax. Please read the thread properly.
I am not asking how to use distinct in a select query. I probably
shouldn't have been posting articles here if i din't know that. Please
think twice before replying and also go thru the thread twice!!
Re: Just wondering... David Portas
12/17/2006 12:29:01 AM
[quoted text, click to view]

In 2005:

Msg 4104, Level 16, State 1, Line 8
The multi-part identifier ".tbl.Col1" could not be bound.

Seems like a minor bug in 2000 that it fails to detect the error.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
Re: Just wondering... Shocky
12/17/2006 12:31:15 AM
@Mike
select distinct.tab1.col1 from tab1 works fine as well

@Hari
Please excuse

@David
Think so too

On Dec 17, 1:29 pm, "David Portas"
[quoted text, click to view]
Re: Just wondering... Hari Prasad
12/17/2006 2:09:20 AM
Hello,

No need of a period (.) aftet Distinct

SELECT Distinct Col1 from Tab1

Thanks
Hari

[quoted text, click to view]

Re: Just wondering... Mike C#
12/17/2006 2:50:45 AM
How does the following work for you?

select distinct.tab1.Col1
from tab1

[quoted text, click to view]

AddThis Social Bookmark Button