Written by
in
ใน MS SQL Server มี Stored Procedure ตัวหนึ่งที่มีประโยชย์ในการจะทำอะไรกับ Table ทุก Table ใน Database ตัวอย่างการใช้ Stored Procedure sp_MSForEachTable
EXEC sp_MSForEachTable ‘SELECT ”?”, COUNT(*) FROM ?’ หรือ sp_MSforeachtable @command1=” declare @tmp int select @tmp=count(*) from ? Print ‘Table Name 😕 |’ + convert(nvarchar, @tmp) ”
EXEC sp_MSforeachtable @command1=”print ‘Rebuilding indexes for ?’ ALTER INDEX ALL ON ? REBUILD WITH (FILLFACTOR = 90)” GO
EXEC sp_MSforeachtable @command1=”print ‘Reorganizing indexes for ?’ ALTER INDEX ALL ON ? REORGANIZE” GO
Your email address will not be published. Required fields are marked *
Comment *
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.
Δ
Leave a Reply