Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 123»»»

Fix users for SQL 7 thru 2008 Expand / Collapse
Author
Message
Posted Thursday, February 4, 2010 5:41 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, May 26, 2014 7:50 AM
Points: 310, Visits: 94
Comments posted to this topic are about the item Fix users for SQL 7 thru 2008
Post #860066
Posted Friday, February 5, 2010 9:05 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 5, 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
Post #860558
Posted Friday, February 5, 2010 9:19 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, May 26, 2014 7:50 AM
Points: 310, Visits: 94
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
Post #860578
Posted Friday, February 5, 2010 2:31 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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!!!!!!!!!!
Post #860853
Posted Saturday, February 6, 2010 11:53 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, July 18, 2014 12:37 PM
Points: 312, Visits: 1,098
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



Post #861144
Posted Saturday, February 6, 2010 12:06 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 4:10 PM
Points: 21,211, Visits: 14,904
Thanks - nice script.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #861150
Posted Monday, February 8, 2010 8:19 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, May 26, 2014 7:50 AM
Points: 310, Visits: 94
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.
Post #861718
Posted Monday, February 8, 2010 9:55 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, July 18, 2014 12:37 PM
Points: 312, Visits: 1,098
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 ' '.



Post #861830
Posted Monday, February 8, 2010 10:22 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, May 26, 2014 7:50 AM
Points: 310, Visits: 94
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.
Post #861853
Posted Monday, February 8, 2010 11:19 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, July 18, 2014 12:37 PM
Points: 312, Visits: 1,098
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



Post #861909
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse