List all tables in a sql server database using a query || Fetch all tables from a database in sql

preview_player
Показать описание
In this video we will discuss, writing a transact sql query to list all the tables in a sql server database. This is a very common sql server interview question.

Object explorer with in sql server management studio can be used to get the list of tables in a specific database. However, if we have to write a query to achieve the same, there are 3 system views that we can use.
1. SYSOBJECTS - Supported in SQL Server version 2000, 2005 & 2008
2. SYS.TABLES - Supported in SQL Server version 2005 & 2008
3. INFORMATION_SCHEMA.TABLES - Supported in SQL Server version 2005 & 2008

-- Gets the list of tables only
Select * from SYSOBJECTS where XTYPE='U'
-- Gets the list of tables only
Select * from SYS.TABLES
-- Gets the list of tables and views
select * from INFORMATION_SCHEMA.TABLES

To get the list of different object types (XTYPE) in a database
Select Distinct XTYPE from SYSOBJECTS

Executing the above query on my SAMPLE database returned the following values for XTYPE column from SYSOBJECTS
IT - Internal table
P - Stored procedure
PK - PRIMARY KEY constraint
S - System table
SQ - Service queue
U - User table
V - View
Рекомендации по теме
Комментарии
Автор

bro i am literally crying bro.
this video is very helpful for me.
i searching this video from i week for my mini college project.
thank you so much bro. 🤩☺😇

sumodmetre
Автор

can you do a video to display only some fields records from a SQL (table )database. after clicking a id or one field to go to full detail page (another page). thanks in PHP please use UNION key word to combine the table records.

krishanlanka
Автор

Bro filmora9 ki tara Sony Vegas 16 orr adobe premier pro ka crack do ne

basantchouhan