0
I would like to delete all the records from the tables of my database, but some tables cannot be deleted, here in my case for example I have an average of 20 tables of which 6 cannot be erased the records. Is there any way to do that?
0
I would like to delete all the records from the tables of my database, but some tables cannot be deleted, here in my case for example I have an average of 20 tables of which 6 cannot be erased the records. Is there any way to do that?
0
You can recover the name of all the tables in the database and run the delete command. example:
DECLARE @sql NVARCHAR(max)=''
SELECT @sql += ' DELETE FROM ' + QUOTENAME(s.NAME) + '.' + QUOTENAME(t.NAME) + '; '
FROM sys.tables t
JOIN sys.schemas s
ON t.[schema_id] = s.[schema_id]
WHERE t.type = 'U' AND t.NAME NOT IN ('','','','')
Exec sp_executesql @sql
Watch the line: AND t.NAME NOT IN ('','','','')
inside the simple quotes you should put the name of the tables that DO NOT WANT TO DELETE the data.
Browser other questions tagged database sql-server
You are not signed in. Login or sign up in order to post.