Click here to Skip to main content
Click here to Skip to main content

Tagged as

Loop through all tables in SQL Server

, 25 Feb 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
Use this when you want to perform a task on all tables in a database
sp_MSforeachtable is a stored procedure used to loop through all the tables in the database. We can use this in different situations. For example, we want to run command to disable all triggers, then we could write that like this:
sp_msforeachtable "ALTER TABLE ? DISABLE TRIGGER all"
? will be replaced with table name.
I think you will enjoy this.
For details, click here[^]


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

code in play
Software Developer (Senior)
India India
4+ year experience in Microsoft technologies(C#.Net,ASP.Net, SQL server and Sharepoint).
Follow on   Twitter

Comments and Discussions

GeneralRe: My bad! Sometimes I'm stopped from voting by the limit they ... PinmvpManfred R. Bihy27-Feb-11 21:46 
GeneralReason for my vote of 5 Good tip! 5 PinmvpManfred R. Bihy27-Feb-11 21:44 
GeneralThanks for that useful tip! 5+ PinmvpManfred R. Bihy25-Feb-11 4:31 
GeneralRe: i think u forget to vote.. ha ha :) Pinmembercode in play25-Feb-11 5:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150327.1 | Last Updated 25 Feb 2011
Article Copyright 2011 by code in play
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid