Menghapus semua record di semua tabel di Database (SQL Server)

Script atau query (Procedure) yang digunakan untuk menghapus seluruh record di database SQL Server


Ketika kita sedang dalam tahap pembuatan program biasanya kita sering melakukan uji coba run script yang melibatkan operasi database (SQL Server), seperti script untuk insert, edit atau delete record di database. Ketika program sudah jadi biasanya kita ingin agar databasenya balik kekondisi ketika baru di buat alias recordnya tidak ada, nah berikut adalah script (Procedure) yang saya temukan untuk menghapus seluruh record di database:

Script menghapus semua record di semua tabel di Database


CREATE PROCEDURE sp_EmplyAllTable
AS
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
EXEC sp_MSForEachTable 'DELETE FROM ?'
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'
GO
Script diatas ketika di run di tab query akan menghasilkan sebuah procedure, nah untuk mendapatkan hasilnya rekan2 harus Execute Procedure tersebut.

Semoga Bermanfaat! :D

COMMENTS

BLOGGER: 1
Loading...
Name

Apache,4,Bisnis Online,1,Blog,1,Cpanel,1,CSS,1,Database,1,Framework,1,Hacking,3,HTML,1,HTML and CSS,2,Info,2,Javascript,2,Javascript and AJAX,5,Keamanan Web,1,linux,2,MySQL,3,Networking,1,Open GL,1,Optimasi Website,7,Pemrograman java,1,Pemrograman web,5,PHP,7,phpMyAdmin,1,SEO,4,SQL Injection,3,SQL Server,12,SQLMap,3,Website,1,Xampp,1,
ltr
item
Nanang Gunawan Blog: Menghapus semua record di semua tabel di Database (SQL Server)
Menghapus semua record di semua tabel di Database (SQL Server)
Script atau query (Procedure) yang digunakan untuk menghapus seluruh record di database SQL Server
https://3.bp.blogspot.com/-NngwrpYmEfU/WONK3iJy_0I/AAAAAAAAAtY/FSfjdcAVNegBPaYsaiL9v3mC8HqmWguLACLcB/s1600/Menghapus%2Bsemua%2Brecord%2Bdi%2Bsemua%2Btabel%2Bdi%2BDatabase%2BSQL%2BServer.jpg
https://3.bp.blogspot.com/-NngwrpYmEfU/WONK3iJy_0I/AAAAAAAAAtY/FSfjdcAVNegBPaYsaiL9v3mC8HqmWguLACLcB/s72-c/Menghapus%2Bsemua%2Brecord%2Bdi%2Bsemua%2Btabel%2Bdi%2BDatabase%2BSQL%2BServer.jpg
Nanang Gunawan Blog
http://www.nananggunawan.com/2012/03/menghapus-semua-record-di-semua-tabel_06.html
http://www.nananggunawan.com/
http://www.nananggunawan.com/
http://www.nananggunawan.com/2012/03/menghapus-semua-record-di-semua-tabel_06.html
true
4195327445586723627
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy