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

Tagged as

Go to top

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[^]

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).
Follow on   Twitter

Comments and Discussions

 
GeneralThanks for that useful tip! 5+ PinmvpManfred R. Bihy25-Feb-11 3:31 
GeneralRe: i think u forget to vote.. ha ha :) Pinmembercode in play25-Feb-11 4:03 
i think u forget to vote..
 
ha ha Smile | :)

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 | Mobile
Web01 | 2.8.140926.1 | Last Updated 25 Feb 2011
Article Copyright 2011 by code in play
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid