Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

sql get tables from current database you working with

-- note for Microsoft SQL Server
-- getting tables in database you are working with

DECLARE @dbname AS varchar(max)
SET @dbname = (SELECT DB_NAME())
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_CATALOG=@dbname

-- getting tables in specific database

DECLARE @dbname AS varchar(max)
SET @dbname = 'my specific database name'
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_CATALOG=@dbname



 
PREVIOUS NEXT
Tagged: #sql #tables #current #database #working
ADD COMMENT
Topic
Name
6+6 =