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.
| Author |
Topic |
|
lotek
Starting Member
42 Posts |
Posted - 2005-10-03 : 13:41:31
|
| I want to write a select statement that can get a result set of each field & parent table in a view.So something likefield1 table1field2 table1field3 table2etc..Possible?ThanksMatt |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-10-04 : 00:37:35
|
| Is this?Select T1.field1,T1.field2,T2.field3 from Table1 T1 inner join Table2 T2 on T1.column1=T2.Column1MadhivananFailing to plan is Planning to fail |
 |
|
|
lotek
Starting Member
42 Posts |
Posted - 2005-10-04 : 12:16:35
|
| I should have been more clear, something like the information_schema.columns except i also want to return the original table name of the columns. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-10-05 : 00:47:26
|
| Select column_Name, Table_Name from Information_Schema.columns order by 2, 1MadhivananFailing to plan is Planning to fail |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-10-05 : 00:53:10
|
since you do know which column came from which table you canconcatenate each column value with e.g. 'Table1' or 'Table2'like..Select ('Table1.' + T1.field1) as 'field1','Table1' + ...each field will be considered as string type oryou can change the column name to [ as 'table1-field1'] and each column can still retain their own datatypesquote: Originally posted by lotek I should have been more clear, something like the information_schema.columns except i also want to return the original table name of the columns.
--------------------keeping it simple... |
 |
|
|
|
|
|