|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, March 22, 2013 1:30 PM
Points: 298,
Visits: 87
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, February 05, 2010 9:01 AM
Points: 1,
Visits: 0
|
|
Two things I noticed that I added to the script:
First, I added brackets around the @Database definition in the cursor. This allows for database names with periods etc.
Second, I added a check for read only databases when attempting to 'Fix' so the process does not fail.
Otherwise, good job!
Flar
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, March 22, 2013 1:30 PM
Points: 298,
Visits: 87
|
|
Thanks Flar, I had already stumbled upon the requirement for the brackets on the database names when I ran this script on one of my older database servers. I know that I should always use the brackets but they drive me crazy But I added them anyway.
I hadn't thought about the read only... I'll look into that. 
MT
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, February 22, 2010 11:48 AM
Points: 1,
Visits: 3
|
|
| This is the most wonderful script ever!!!!!!!!!!
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Today @ 1:52 PM
Points: 306,
Visits: 1,016
|
|
Hello,
Nicely done! Unfortunately I'm having a problem executing on a SQL 2005 server. Do you have an updated script I could use?
I think everyone should have this script including MS!
Rudy
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Today @ 10:25 AM
Points: 18,754,
Visits: 12,337
|
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, March 22, 2013 1:30 PM
Points: 298,
Visits: 87
|
|
Yes, I do have an update. I have posted it but so far I have not seen my changes show up on the website. It now handles read only datbases better, and I fixed a couple of errors I found.
My latest is now posted. If there is still an error in 2005, let me know.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Today @ 1:52 PM
Points: 306,
Visits: 1,016
|
|
Thanks for updating the file. Unfortunately I'm still having issues with the creation of the sp. I've copied and pasted the script and change the ALTER command to CREATE but get the following errors. (I'm executing this on a x64 version of SQL 2005).
Any ideas on how to fix this would be great.
Rudy
Msg 102, Level 15, State 1, Line 3 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 16 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 17 Incorrect syntax near ' '. Msg 137, Level 15, State 2, Line 17 Must declare the scalar variable "@DBName". Msg 102, Level 15, State 1, Line 18 Incorrect syntax near ' '. Msg 137, Level 15, State 2, Line 18 Must declare the scalar variable "@User". Msg 102, Level 15, State 1, Line 20 Incorrect syntax near ' '. Msg 137, Level 15, State 2, Line 20 Must declare the scalar variable "@DBName". Msg 137, Level 15, State 2, Line 21 Must declare the scalar variable "@Action". Msg 137, Level 15, State 2, Line 22 Must declare the scalar variable "@User". Msg 137, Level 15, State 2, Line 24 Must declare the scalar variable "@DBName". Msg 102, Level 15, State 1, Line 25 Incorrect syntax near ' '. Msg 137, Level 15, State 2, Line 26 Must declare the scalar variable "@DBName". Msg 137, Level 15, State 2, Line 29 Must declare the scalar variable "@DBName". Msg 102, Level 15, State 1, Line 34 Incorrect syntax near ' '. Msg 137, Level 15, State 2, Line 35 Must declare the scalar variable "@DBName". Msg 102, Level 15, State 1, Line 37 Incorrect syntax near ' '. Msg 137, Level 15, State 2, Line 38 Must declare the scalar variable "@Action". Msg 137, Level 15, State 2, Line 40 Must declare the scalar variable "@Action". Msg 137, Level 15, State 2, Line 43 Must declare the scalar variable "@Action". Msg 102, Level 15, State 1, Line 50 Incorrect syntax near ' '. Msg 137, Level 15, State 2, Line 51 Must declare the scalar variable "@err_flag". Msg 102, Level 15, State 1, Line 81 Incorrect syntax near ' '. Msg 137, Level 15, State 1, Line 92 Must declare the scalar variable "@ParmDefinition". Msg 102, Level 15, State 1, Line 94 Incorrect syntax near ' '. Msg 137, Level 15, State 2, Line 94 Must declare the scalar variable "@DBName". Msg 102, Level 15, State 1, Line 97 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 100 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 105 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 108 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 112 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 114 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 116 Incorrect syntax near ' '. Msg 137, Level 15, State 2, Line 116 Must declare the scalar variable "@Database". Msg 102, Level 15, State 1, Line 119 Incorrect syntax near ' '. Msg 137, Level 15, State 2, Line 119 Must declare the scalar variable "@Database". Msg 137, Level 15, State 2, Line 120 Must declare the scalar variable "@Database". Msg 137, Level 15, State 2, Line 121 Must declare the scalar variable "@DBReadOnly". Msg 137, Level 15, State 2, Line 123 Must declare the scalar variable "@cmd". Msg 137, Level 15, State 2, Line 124 Must declare the scalar variable "@Action". Msg 137, Level 15, State 2, Line 124 Must declare the scalar variable "@cmd". Msg 137, Level 15, State 2, Line 126 Must declare the scalar variable "@cmd". Msg 137, Level 15, State 2, Line 127 Must declare the scalar variable "@cmd". Msg 137, Level 15, State 2, Line 129 Must declare the scalar variable "@User". Msg 102, Level 15, State 1, Line 132 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 136 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 141 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 145 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 149 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 151 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 152 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 153 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 155 Incorrect syntax near ' '. Msg 137, Level 15, State 2, Line 155 Must declare the scalar variable "@name". Msg 102, Level 15, State 1, Line 158 Incorrect syntax near ' '. Msg 137, Level 15, State 2, Line 158 Must declare the scalar variable "@Action". Msg 137, Level 15, State 2, Line 160 Must declare the scalar variable "@name". Msg 137, Level 15, State 2, Line 161 Must declare the scalar variable "@name". Msg 137, Level 15, State 2, Line 162 Must declare the scalar variable "@name". Msg 137, Level 15, State 2, Line 164 Must declare the scalar variable "@Action". Msg 137, Level 15, State 2, Line 166 Must declare the scalar variable "@name". Msg 137, Level 15, State 2, Line 167 Must declare the scalar variable "@name". Msg 137, Level 15, State 2, Line 169 Must declare the scalar variable "@Action". Msg 137, Level 15, State 2, Line 171 Must declare the scalar variable "@name". Msg 137, Level 15, State 1, Line 173 Must declare the scalar variable "@login_sid". Msg 137, Level 15, State 2, Line 174 Must declare the scalar variable "@sid". Msg 137, Level 15, State 2, Line 176 Must declare the scalar variable "@name". Msg 137, Level 15, State 2, Line 177 Must declare the scalar variable "@SvrLevel". Msg 102, Level 15, State 1, Line 180 Incorrect syntax near ' '. Msg 137, Level 15, State 2, Line 181 Must declare the scalar variable "@cmd". Msg 102, Level 15, State 1, Line 186 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 189 Incorrect syntax near ' '. Msg 137, Level 15, State 2, Line 193 Must declare the scalar variable "@Action". Msg 137, Level 15, State 2, Line 195 Must declare the scalar variable "@name". Msg 137, Level 15, State 2, Line 197 Must declare the scalar variable "@name". Msg 137, Level 15, State 2, Line 198 Must declare the scalar variable "@SvrLevel". Msg 102, Level 15, State 1, Line 201 Incorrect syntax near ' '. Msg 137, Level 15, State 2, Line 202 Must declare the scalar variable "@cmd". Msg 102, Level 15, State 1, Line 207 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 210 Incorrect syntax near ' '.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, March 22, 2013 1:30 PM
Points: 298,
Visits: 87
|
|
I cut and pasted the script from the listing and I got the same errors. I went through and replaced all the white space (tabs, spaces etc.) at the beginnings and endings of all the lines (and sometimes I had to replace the spaces between words) and the procedure compiled after that. Must be some kind of special characer that crept in when posting the script. Sheesh!
Hope that fixes it for you.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Today @ 1:52 PM
Points: 306,
Visits: 1,016
|
|
Yup that's it. When I copied and pasted into SSMS there seems to be no problem, but when I pasted the script into NotePad++ it all showed up. Once I removed the characters the sp executed properly.
Now the for the final question. When I execute the script with the FixALL option I get the following error message.
Msg 259, Level 16, State 1, Line 1 Ad hoc updates to system catalogs are not allowed.
Have you seen this before and if so how did you correct it.
Thanks again for helping me out. This is an EXCELLENT script and should be in the Best of SQL Central.
Rudy
|
|
|
|