The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. July 31, 2014, 02:24:58 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: MSSQL Show All Tables in a DB  (Read 10696 times)
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10093



View Profile
« on: October 08, 2007, 09:49:33 PM »

NBs helped me out a great deal today and got me going forward with a MSSQL task. Thanks man, very much.

Karma required I throw something back, so here is how to see all the tables in a database in MSSQL. I put it here because I had to google for it and better here than there. This is stoopid simple but nice to have:

Code:
mssql_connect('theserver', 'username', 'password');
mssql_select_db('thedb');
mssql_query("select name from sysobjects where type='u'");
while ($row = mssql_fetch_row())
print "{$row[0]}\n";

Another interesting tidbit: when doing my first SELECT today, I got a permission denied on the table I was selecting from. Even though my default database was correct, I still had to mssql_select_db as shown above to get things to work properly.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #1 on: October 09, 2007, 01:53:13 PM »

Thanks Perk.

I think in oracle you query system.tab

Code:
SELECT * FROM system.tab

In case anyone ever needs to know how much I remember from college...
Logged

hai
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!