Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to drop all tables in sql

USE Databasename

SELECT  'DROP TABLE [' + name + '];'
FROM    sys.tables
Comment

SQL Query to delete all the tables in a database

BY LOVE

EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
DECLARE @sql NVARCHAR(max)=''

SELECT @sql += ' Drop table ' + QUOTENAME(TABLE_SCHEMA) + '.'+ QUOTENAME(TABLE_NAME) + '; '
FROM   INFORMATION_SCHEMA.TABLES
WHERE  TABLE_TYPE = 'BASE TABLE'
Exec Sp_executesql @sql
Comment

sql drop all tables

DECLARE @sql NVARCHAR(max)=''

SELECT @sql += ' Drop table ' + QUOTENAME(TABLE_SCHEMA) + '.'+ QUOTENAME(TABLE_NAME) + '; '
FROM   INFORMATION_SCHEMA.TABLES
WHERE  TABLE_TYPE = 'BASE TABLE'

Exec Sp_executesql @sql
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql dump 
Sql :: postgresql powershell query 
Sql :: match in sql server 
Sql :: dump multiple tables mysql 
Sql :: sql get month 
Sql :: postgres select except 
Sql :: what is denormalization in sql 
Sql :: mysql date_format 
Sql :: sql describe 
Sql :: ERROR: permission denied for table accounts postgresql 13 
Sql :: delete insert record in sql server 
Sql :: sql order of operations 
Sql :: not operator in sql 
Sql :: mysql sublime build system 
Sql :: last 2 mins sql server 
Sql :: create postgres role and database for bitbucket 
Sql :: sql store procedure 
Sql :: mysql join same table multiple times group by 
Sql :: how to get second highest salary in each department in sql 
Sql :: oracle insert from select 
Sql :: SELECT ALL TABLE INFO 
Sql :: oracle all columns 
Sql :: how to dump .csv file into mysql 
Sql :: sqlalchemy existing db file 
Sql :: db count rows 
Sql :: sql query print strings and int 
Sql :: timestamp to date sql server 
Sql :: sql: extract day text from datetime value 
Sql :: get last inserted primary key 
Sql :: what is table in sql 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =