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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans