aebstract Posted February 11, 2010 Share Posted February 11, 2010 I've never worked in microsoft sql, so I am not sure if it is in any way similar to mysql or completely different. I'm also somewhat limited on support and what I have access to. I can run php and have full ftp access. I can probably run .net as well, as the site is running on dotnetnuke and from what I've read that is based off of .net. I have no idea whatsoever how to even look at .net, so I would prefer staying with php. Is there a way to use the sql server info and view all database information? I hope it is structured somewhat similar to mysql, as in having tables, columns/rows, etc. I don't know what tables I have, don't know anything really. I'm going to have to start working on a huge port out and port in to a new system (which will be mysql) and this is my first step. Any advice/info/tips is awesome. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/191785-view-all-db-info/ Share on other sites More sharing options...
Mchl Posted February 11, 2010 Share Posted February 11, 2010 You can fetch this information from information_schema database http://www.aspfree.com/c/a/MS-SQL-Server/A-Primer-on-INFORMATIONSCHEMA-Views-in-SQL-Server-2000/ Quote Link to comment https://forums.phpfreaks.com/topic/191785-view-all-db-info/#findComment-1010830 Share on other sites More sharing options...
aebstract Posted February 11, 2010 Author Share Posted February 11, 2010 Okay, I'm sort of stuck on actually displaying the information. <?php $server = '1'; $link = mssql_connect($server, '2', '3'); if (!$link) { die('Something went wrong while connecting to MSSQL'); } $query = mssql_query("SELECT * FROM information_schema.tables"); while($r=mssql_fetch_array($query)) { echo mssql_result($query); } ?> Blank page, I'm assuming I'm connected as I get no error and this is the method that was used as demonstration in the php manual. So that brings me to actually displaying the information, which I usually would do a while and loop through each row of information in a table, though this is obviously different and I'm not looping through like that. How can I echo out the information so I can see it? Quote Link to comment https://forums.phpfreaks.com/topic/191785-view-all-db-info/#findComment-1010842 Share on other sites More sharing options...
Mchl Posted February 11, 2010 Share Posted February 11, 2010 How about while($r=mssql_fetch_array($query)) { print_r($r); } Quote Link to comment https://forums.phpfreaks.com/topic/191785-view-all-db-info/#findComment-1010844 Share on other sites More sharing options...
aebstract Posted February 11, 2010 Author Share Posted February 11, 2010 Isn't print_r suppose to format the array nicely so you can look at it and it make sense? Cause this is displaying like a paragraph, and there is a LOT of information. If nothing else, this at least gets me that information! Thanks EDIT: was thinking of <pre> thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/191785-view-all-db-info/#findComment-1010863 Share on other sites More sharing options...
Mchl Posted February 11, 2010 Share Posted February 11, 2010 This is array formatted nicely. You just have to view source to see it I used print_r only as an example. $r is an array, and you can display it however you wish. You can also save results to a file, for future reference. Quote Link to comment https://forums.phpfreaks.com/topic/191785-view-all-db-info/#findComment-1010866 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.