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 2000 Forums
 SQL Server Development (2000)
 is it possible to have same column name for 2 colu

Author  Topic 

Sarakumar
Posting Yak Master

108 Posts

Posted - 2006-08-01 : 04:28:20
Hai friends,
i have got a doubt. For two Columns i need to have same column name.
Is it possible?
select sname as [name],
candidate as [name],
sid from tbl

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-08-01 : 04:32:40
Yes it is allow.

Example :

use Northwind

select CompanyName as [name],
ContactName as [name]
from Customers


But why do you want to do this ?


KH

Go to Top of Page

Sarakumar
Posting Yak Master

108 Posts

Posted - 2006-08-01 : 04:44:46
quote:
Originally posted by khtan

Yes it is allow.

Example :

use Northwind

select CompanyName as [name],
ContactName as [name]
from Customers


But why do you want to do this ?


KH





i wounder, but if i try u query is working. but in my requirement im applying this logic for case statmet
case when sname like 'r%' then true else false end as [sname],
case when sname like 'm%' then true else false end as [sname],
but i get the output as sname,sname1...that's y i asked..
any idea???

Go to Top of Page

Sarakumar
Posting Yak Master

108 Posts

Posted - 2006-08-01 : 04:48:48
Sorry, i think it is the problem in the front end...sorry for the trouble
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-08-01 : 04:50:17
do you get this when running in Query Analyser ?


KH

Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2006-08-01 : 05:48:17
Would you not be better off with
select sname as [name], sid from tbl
union
select candidate as [name], sid from tbl


What you are trying to do is not-advised...and given you are running into problems...difficult to work with
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-01 : 11:15:22
But
case when sname like 'r%' then true else false end as [sname],
case when sname like 'm%' then true else false end as [sname],

can be rewritten as

case when (sname like 'r%' or sname like 'm%') then true else false end as [sname]

Madhivanan

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

- Advertisement -