10-04-20, 05:28 AM
(10-04-20, 04:22 AM)asemshahen5 كتب :PHP كود :
use [TestTestD]
declare @SQL nvarchar(max)=''
declare @SQLV nvarchar(max)=''
declare @SQLT nvarchar(max)=''
SELECT @SQL = STUFF((SELECT ', ' + quotename(TABLE_SCHEMA) + '.' + quotename(TABLE_NAME)
FROM INFORMATION_SCHEMA.TABLES WHERE Table_Name LIKE '%'
FOR XML PATH('')),1,2,'')
SET @SQLT = 'DROP TABLE ' + @SQL
SET @SQLV = 'DROP View ' + @SQL
PRINT @SQLT
PRINT @SQLV
EXECUTE (@SQLT) -- uncomment to actually delete the tables
EXECUTE (@SQLV) -- uncomment to actually delete the View
الف شكر اخي عاصم جزاك الله عنا كل خير
طبقت الكود ونجح في انه حدف جميع الجداول ولكن ظهر الخطأ التالي
PHP كود :
DROP TABLE [dbo].[Table_1], [dbo].[Table_2], [dbo].[Table_3], [dbo].[Table_4], [dbo].[Table_5]
DROP View [dbo].[Table_1], [dbo].[Table_2], [dbo].[Table_3], [dbo].[Table_4], [dbo].[Table_5]
Msg 3701, Level 11, State 5, Line 1
Cannot drop the view 'dbo.Table_1', because it does not exist or you do not have permission.
Msg 3701, Level 11, State 5, Line 1
Cannot drop the view 'dbo.Table_2', because it does not exist or you do not have permission.
Msg 3701, Level 11, State 5, Line 1
Cannot drop the view 'dbo.Table_3', because it does not exist or you do not have permission.
Msg 3701, Level 11, State 5, Line 1
Cannot drop the view 'dbo.Table_4', because it does not exist or you do not have permission.
Msg 3701, Level 11, State 5, Line 1
Cannot drop the view 'dbo.Table_5', because it does not exist or you do not have permission.

