Click here to Skip to main content
13,597,813 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


4 bookmarked
Posted 24 Feb 2011
Licenced CPOL

Loop through all tables in SQL Server

, 25 Feb 2011
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).

You may also be interested in...


Comments and Discussions

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

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

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

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