Neal Waterstreet

  • Home
  • About
  • Book Reviews
    • 2018 Reading List
    • 2017 Reading List
    • 2016 Reading List
    • 2015 Reading List
    • 2014 Reading List
    • 2013 Reading List
  • Projects
    • OBi200
    • DS716+ memory upgrade
    • Cord cutting
  • Presentations
  • Contact

Delete all rows in database

October 10, 2011 by neal Leave a Comment

I recently ran into a situation where I had to truncate an entire database. Usually not a good sign, but this was to clean out a archive/logging database for someone to practice on. The script below works well and is based on sp_ms_foreachtable, which is unsupported but very useful.

--First, disable all constraints on all tables.
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT ALL"
--Second, delete the data from all tables.
EXEC sp_MSForEachTable "DELETE FROM ?"
--Third, re -enable all of the constraints
EXEC sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT ALL"
--Optionally, you can use DBCC CHECKIDENT to reseed all of the tables staring at 0 or whatever you want.
EXEC sp_MSforeachtable "DBCC CHECKIDENT ( '?', RESEED, 0)"

Filed Under: Scripts

New theme for the blog

October 6, 2011 by neal Leave a Comment

I have finally changed the theme on the blog. I still have not figured out all the details and completed the customization, mostly due to the new theme having many more options.

Now for some content…

Filed Under: Misc Tagged With: blog

Testing

October 3, 2011 by neal Leave a Comment

Posting from my phone.

Filed Under: Misc

  • « Previous Page
  • 1
  • …
  • 28
  • 29
  • 30
  • 31
  • Next Page »
July 2025
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  
« Mar    

Blogroll

  • Atlanta MDF
  • Atlanta Microsoft Business Intelligence Group
  • Atlanta Modern Excel User Group
  • Chris Webb's BI Blog
  • codegumbo
  • Lance England
  • PowerPivotPro
  • Prologika
  • SQLBI

Tags

#SQLSatATLBI Aereo at Atlanta Microsoft BI Azure Azure DataFest Backups Batch Certification changeset Chicago Conference CrashPlan Data Modeling Data Quality DAX Deployment DVR Entity-based staging Error Messages Excel Filter Goals Headphones Healthcare Leaf Tables MDM MDS MDS Add-in for Excel Oops! Something went wrong PASS Healthcare VC Power BI Power Pivot review Roku SQLSaturday SQL Saturday 800 SQLSaturday Atlanta BI SSIS Streaming Subscription View Time Training Validation Version Flag

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 2025 · Minimum Pro Theme on Genesis Framework · WordPress · Log in