web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Use sp_MSforeachdb but on a selected databases in the server

(1) ShareShare
ReportReport
Posted on by 80

Hello. Please assist me. I am using sp_MSforeachdb and it is working so well with the below sytax:

DECLARE @command varchar(1000) 
SELECT @command = 
    'USE [?] exec sp_helpfile'         ---- exec sp_helpfile =query,you can replace how u wish.
EXEC sp_MSforeachdb @command

Now, my challenge is that there are a lot of databases (200) inside the server, some I do not have access to or they are not managed by me. So I want to use sp_MSforaechdb but only for the databases(20) that are of my responsibility. Please assist me with the syntax to include the loop on the above syntax that is already working.

Thanks

*This post is locked for comments

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans