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)
 list alias name with column name in a view

Author  Topic 

nega
Starting Member

1 Post

Posted - 2009-06-07 : 08:04:48
I have a view like

create a view view1 as select employees.empname as name,employees.dob as dateofbirth from employees

i want to get the column list used in view1 like below

originalcolumn - aliasname - tablename
-----------------------------------------------------
empname - name - employees
dob - dataofbirth - employees


is there a way to get this in sql server 2005?


webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-07 : 08:43:36
There is no easy way to get this information.
Here comes an earlier thread for this issue.

Greetings
Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-07 : 09:08:57
Don't think it is possible and as webfred said "no easy way" as the alias in a view can be coming from more than 1 table and column

example

select col_alias = t1.col1 + t2.col2 + t3.col2
from table1 t1 inner join table2 t2 on t1.pk = t2.pk
inner join table3 t3 on t1.fk = t3.pk


or maybe a coming from several layer of derived table. And from each derived table, maybe a combination of several columns

select col_alias = a.col1
from (
select col1 = t1.col2 + t2.col3 + t3.col4
from (
< . . . >
) t1
inner join table2 t2 on . . .
inner join table3 t3 on . . .
) a


If you really need to do this . . . all i can says is GOOD LUCK.

But maybe you can explain why do you need to do this in the first place ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-07 : 09:20:04
quote:
Originally posted by webfred

There is no easy way to get this information.
Here comes an earlier thread for this issue.

Greetings
Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.


Oops - I have forgotten to insert the link...
Here it comes:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=117286


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -