yeago Posted March 21, 2006 Share Posted March 21, 2006 I am attempting to get the microsoft SQL equivalent of "show columns from table" from MySQL.HOW? Link to comment https://forums.phpfreaks.com/topic/5440-how-to-return-a-tables-column-names/ Share on other sites More sharing options...
Barand Posted May 14, 2006 Share Posted May 14, 2006 Here's one way[code]$result = mssql_query("SELECT TOP 1 * FROM tablename");$row = mssql_fetch_assoc($result);foreach ($row as $colname => $value) { echo $colname . '<BR />';}[/code] Link to comment https://forums.phpfreaks.com/topic/5440-how-to-return-a-tables-column-names/#findComment-35812 Share on other sites More sharing options...
GeoffOs Posted May 17, 2006 Share Posted May 17, 2006 You can use a query like this:[code]select * from information_schema.columns where table_name = '<<your table name>>'[/code] Link to comment https://forums.phpfreaks.com/topic/5440-how-to-return-a-tables-column-names/#findComment-36640 Share on other sites More sharing options...
fractil Posted June 23, 2006 Share Posted June 23, 2006 Continuing with GeoffOs post, I find it helpful to include the database name in the FROM clause.just do a select on the information_schema.COLUMNS table:select column_namefrom <dbname>.information_schema.columnswhere table_name = '<tablename>'see: [a href=\"http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ia-iz_4pbn.asp\" target=\"_blank\"]http://msdn.microsoft.com/library/default...._ia-iz_4pbn.asp[/a]Cheers! Link to comment https://forums.phpfreaks.com/topic/5440-how-to-return-a-tables-column-names/#findComment-48809 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.