Stored Procedure sp_MSForEachTable จัดการได้ทุก Table ใน Database

ใน MS SQL Server มี Stored Procedure ตัวหนึ่งที่มีประโยชย์ในการจะทำอะไรกับ Table ทุก Table ใน Database ตัวอย่างการใช้ Stored Procedure sp_MSForEachTable นับจำนวน record ทั้งหมดของทุก Table ใน Database EXEC sp_MSForEachTable ‘SELECT ”?”, COUNT(*) FROM ?’ หรือ sp_MSforeachtable @command1=” declare @tmp int select @tmp=count(*) from ? Print ‘Table Name 😕 |’ + convert(nvarchar, @tmp) ” Rebuilding indexes on every table in … Read more