|
I want to know, is there any script so i can change DB owner to SA for all databases in sql server in one attempt? please help me out if some have info. i will be thankfull. sumit
(comments are locked)
|
when i run i EXEC sp_MSforeachdb 'EXEC [?]..sp_changedbowner ''sa'' am getting below error: Msg 105, Level 15, State 1, Line 1 Unclosed quotation mark after the character string 'EXEC [?]..sp_changedbowner 'sa''.
Aug 14 '12 at 07:30 AM
SumitRana
add another single quote to the end EXEC sp_MSforeachdb 'EXEC [?]..sp_changedbowner ''sa'''
Aug 14 '12 at 07:42 AM
Kev Riley ♦♦
Stick another ' at the end, thus:
Aug 14 '12 at 07:42 AM
ThomasRushton ♦
Thanks, I missed that single quote, I made the changes in my post.
Aug 14 '12 at 07:46 AM
Cyborg
thanks to all..
Aug 14 '12 at 07:54 AM
SumitRana
(comments are locked)
|
|
I wouldn't use sp_msforeachdb as it has a habit of missing databases completely. I prefer to use a query to build the execution strings so that I can be sure of what I'm executing. Run the following and paste the results back to the query window for executing:
(comments are locked)
|
|
You might also like the PowerShell way... From Buck Woody:
(comments are locked)
|

