sp-msforeachtable Questions

18

Solved

I'm trying to write a script that will completely empty a SQL Server database. This is what I have so far: USE [dbname] GO EXEC sp_msforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all' EXEC sp_msf...
Fasces asked 9/12, 2011 at 0:30

4

Solved

When I try to rebuild an index on a table: ALTER INDEX ALL ON [dbo].[Allocations] REBUILD that works fine. But when I call EXECUTE sp_msForEachTable 'ALTER INDEX ALL ON ? REBUILD' I reach th...
Loathly asked 1/10, 2012 at 13:53

6

Solved

I am using sp_MSforeachtable to get a rowcount of specific tables in my database. I want these ordered by name. How do I add an ORDER BY clause to sp_MSforeachtable?
Giagiacamo asked 24/8, 2009 at 15:36

7

Solved

By using this statement in SQL Server: EXEC sp_msforeachtable 'DROP TABLE ?' I know it's possible to delete all tables at once. Is there a similar statement for views? I tried this hoping to b...
Dispassionate asked 27/7, 2012 at 14:11

3

Solved

I know that sp_msforeachtable allows to perform queries on all tables. I have 100 tables and I want to perform the same query on 97 tables. I'm using this query: EXEC sp_MSForEachTable "DELETE F...
Trait asked 21/10, 2011 at 17:22

2

Solved

I am trying to write this query to find all tables with specific column with some specific value. This is what I've done so far - EXEC sp_MSforeachtable @command1=' IF EXISTS (SELECT * FROM IN...

3

Solved

It seems that some scripts generated by Enterprise Manager* (or not, it doesn't matter) created check constraints WITH NOCHECK. Now when anyone modifies the table, SQL Server is stumbling across fa...
1

© 2022 - 2024 — McMap. All rights reserved.