If you find this SQL tutorial useful please LIKE and SUBSCRIBE!
In this video I show two techniques of querying a SQL Server database and returning a list of table names.
00:00 - Introduction
00:06 - Querying sp_tables
00:59 - Querying sys.tables
02:54 - Related tutorials
The first technique is to make use of the system stored procedure sp_tables. The second method is to query the table sys.tables.
If you get any errors while using these techniques, or they don't return the data you're expecting then check your SQL user privileges.
Incidentally if you want to join sys.tables and sys.schemas then use this query below:
select sys.schemas.name as 'SchemaName', sys.tables.name as TableName
from sys.tables
inner join sys.schemas on sys.tables.schema_id = sys.schemas.schema_id
Just bear in mind that both of these techniques may return slightly different results sets depending on what database version you're using. The full documentation for sp_tables and sys.tables is available here:
sp_tables reference: [ Ссылка ]
sys.tables reference: [ Ссылка ]
Check this video to return a list of table column names and other properties from any SQL Server table: [ Ссылка ]
Ещё видео!