Timeline for How to delete all rows from all tables in a SQL Server database?
Current License: CC BY-SA 4.0
17 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 4, 2022 at 14:44 | comment | added | Zach Smith | Which words are you struggling with? | |
| Feb 3, 2022 at 13:40 | comment | added | FluidMechanics Potential Flows | oh that's smart, thanks, i don't understand much of the code though, don't really know where to start | |
| Feb 3, 2022 at 8:32 | comment | added | Zach Smith |
Indeed @FluidMechanicsPotentialFlows - the EXECUTE sp_executesql @sql statement is commented out. This is just in case someone were to copy/paste this SQL into SSMS without reading it first
|
|
| Feb 2, 2022 at 19:58 | comment | added | FluidMechanics Potential Flows | Doesn't do anything | |
| S Jul 19, 2021 at 5:37 | history | suggested | Protiguous | CC BY-SA 4.0 |
Corrected casing on stored procedure.
|
| Jul 18, 2021 at 23:17 | review | Suggested edits | |||
| S Jul 19, 2021 at 5:37 | |||||
| Nov 10, 2018 at 11:38 | comment | added | Zach Smith | What version of SQL Server are you using @DouglasGaskell? | |
| Nov 10, 2018 at 2:48 | comment | added | Douglas Gaskell |
Unfortunately this seems to fail if there are FK constraints. The ALTER TABLE bit to disable constraints fails.
|
|
| May 3, 2018 at 10:35 | history | edited | Zach Smith | CC BY-SA 4.0 |
edited to include database name - makes the code callable from within an SP
|
| May 3, 2018 at 10:30 | history | edited | Zach Smith | CC BY-SA 4.0 |
edited to include database name - makes the code callable from within an SP
|
| Jan 30, 2018 at 12:19 | comment | added | Zach Smith | @influent - now it takes non-dbo schemas into account | |
| Jan 30, 2018 at 12:18 | history | edited | Zach Smith | CC BY-SA 3.0 |
adjusted code to work with all schemas
|
| Jan 22, 2018 at 19:03 | comment | added | influent | If you have a table, for example, called test.Table1, where "test" is the schema, your deletes will fail if trying to execute "DELETE FROM Table1". It needs to be DELETE FROM test.Table1. | |
| Jan 20, 2018 at 18:32 | comment | added | Zach Smith | I've never used non dbo schemas, so I wouldn't catch that. But why doesn't it work? I'm not specifying schema anywhere so does it default to dbo only? | |
| Jan 19, 2018 at 22:19 | comment | added | influent | This is great but it doesn't take non-dbo schemas into account. | |
| Mar 1, 2017 at 9:25 | history | edited | Zach Smith | CC BY-SA 3.0 |
Improved answer
|
| Mar 1, 2017 at 9:17 | history | answered | Zach Smith | CC BY-SA 3.0 |