Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How list out all tables in MSSQL?

I'm using the code below to show the tables in my database.

I get "Connected to database" but nothing else. Is my code correct? can I use another way to get the info I need?

<?php 
$link = mssql_connect('HOST', 'user', 'pass');

if (!$link || !mssql_select_db('dbname', $link)) {
    die('Unable to connect or select database!');
}else{
echo"Connected to database";
}


$v = mssql_query("Select name from sysobjects where type like 'u'");
$row = mssql_fetch_array($v);

echo "<br>";  echo $row[0]; echo "<br>";


mssql_free_result($v);
?>
like image 344
ADM Avatar asked Apr 07 '11 10:04

ADM


People also ask

How do I list all the tables in my database?

MySQL SHOW TABLES command example To use the SHOW TABLES command, you need to log on to the MySQL server first. On opening the MySQL Command Line Client, enter your password. Select the specific database. Run the SHOW TABLES command to see all the tables in the database that has been selected.

How can I see tables in SQL Server?

Using SQL Server Management Studio In Object Explorer, select the table for which you want to show properties. Right-click the table and choose Properties from the shortcut menu. For more information, see Table Properties - SSMS.

How do I see total tables in SQL?

The following is the output that displays all the tables in the database "business". In the above, we have 132 tables in the database business. To check the count of tables. mysql> SELECT count(*) AS TOTALNUMBEROFTABLES -> FROM INFORMATION_SCHEMA.


2 Answers

Alternate way, also fetches schema name

SELECT TABLE_CATALOG ,
        TABLE_SCHEMA ,
        TABLE_NAME ,
        TABLE_TYPE
FROM INFORMATION_SCHEMA.TABLES
like image 80
MadBender Avatar answered Sep 17 '22 23:09

MadBender


SELECT * FROM sys.Tables;

Should do the magic :-D

And if u want to see all columns, i would do

SELECT TOP 1 * From Tablename;

so u'll get one row with all Columns, its not perfect but it does the trick if u just want to know sth

like image 43
swisscoder Avatar answered Sep 17 '22 23:09

swisscoder