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 |
kifeda
Posting Yak Master
136 Posts |
Posted - 2006-10-17 : 10:57:07
|
How do I select the actual colmn name of a table? So I have a table called students, with firstname, lastname and studentid. I want to return the actual column names, NOT the data in the columns. Anyone?What about the tables? |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-10-17 : 10:58:36
|
Take a look at selecting from INFORMATION_SCHEMA.COLUMNS and INFORMATION_SCHEMA.TABLES. |
|
|
kifeda
Posting Yak Master
136 Posts |
Posted - 2006-10-17 : 10:59:54
|
where do I find this information? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-10-17 : 11:00:40
|
Books OnLine KH |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-10-17 : 11:48:43
|
Books OnLine is sql server help fileMadhivananFailing to plan is Planning to fail |
|
|
ytz
Starting Member
1 Post |
Posted - 2006-10-18 : 11:02:46
|
SELECT Column_Name = c.Name,Data_Type = t.Name, TableView_Name = o.name, c.length FROM syscolumns cINNER JOIN sysobjects o ON c.id=o.id INNER JOIN systypes t ON c.xtype = t.xtypeWHERE o.Name = Table_Name AND c.Name = Column_Name |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-10-18 : 11:39:05
|
quote: Originally posted by ytz SELECT Column_Name = c.Name,Data_Type = t.Name, TableView_Name = o.name, c.length FROM syscolumns cINNER JOIN sysobjects o ON c.id=o.id INNER JOIN systypes t ON c.xtype = t.xtypeWHERE o.Name = Table_Name AND c.Name = Column_Name
The view INFORMATION_SCHEMA.COLUMNS has all these informationsMadhivananFailing to plan is Planning to fail |
|
|
|
|
|