We help IT Professionals succeed at work.

correct sytax for sp_msforeachdb SQL Server 2005

721 Views
Last Modified: 2013-11-05
I am trying to use the sp_msforeachdb stored procedure to execute the following commands and I cannot get the sysntax correct.  can anyone help?

When I issue this:
sp_msforeachdb 'EXEC dbo.sp_changedbowner @loginame = N'DOMAIN\DomainUser', @map = false'

Open in new window

I get this:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'DOMAIN'.

and when I issue this:
sp_msforeachdb 'EXEC sp_change_users_login 'Auto_fix', 'DOMAIN\DomainUser''

Open in new window

i get this:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'Auto_fix'.
Comment
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Awesome!  Thank you!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.