SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Fix users for SQL 7 thru 2008


Fix users for SQL 7 thru 2008

Author
Message
Mike Tutor
Mike Tutor
SSC-Addicted
SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)

Group: General Forum Members
Points: 403 Visits: 101
Comments posted to this topic are about the item Fix users for SQL 7 thru 2008
flar_Mnementh
flar_Mnementh
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 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
Mike Tutor
Mike Tutor
SSC-Addicted
SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)

Group: General Forum Members
Points: 403 Visits: 101
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 Hehe But I added them anyway.

I hadn't thought about the read only... I'll look into that. Cool

MT
ikunz
ikunz
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 5
This is the most wonderful script ever!!!!!!!!!!
Rudy Panigas
Rudy Panigas
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1370 Visits: 1312
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



SQLRNNR
SQLRNNR
SSC-Forever
SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)

Group: General Forum Members
Points: 40925 Visits: 18565
Thanks - nice script.



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


SQL RNNR

Posting Performance Based Questions - Gail Shaw

Mike Tutor
Mike Tutor
SSC-Addicted
SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)

Group: General Forum Members
Points: 403 Visits: 101
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.
Rudy Panigas
Rudy Panigas
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1370 Visits: 1312
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 ' '.



Mike Tutor
Mike Tutor
SSC-Addicted
SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)SSC-Addicted (403 reputation)

Group: General Forum Members
Points: 403 Visits: 101
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.
Rudy Panigas
Rudy Panigas
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1370 Visits: 1312
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



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search