Click here to Skip to main content
11,581,186 members (57,934 online)
Click here to Skip to main content

Tagged as

Loop through all tables in SQL Server

, 25 Feb 2011 CPOL 13.9K 4
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[^]

License

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

Share

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 
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    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.150603.1 | Last Updated 25 Feb 2011
Article Copyright 2011 by code in play
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid