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


Fix all orphaned users in a database


Fix all orphaned users in a database

Author
Message
gmacdonald
gmacdonald
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 5
Totally agree with Julien, nice when the code works out of the box. Production for me is 2003 Standard SQL 2005. I restore to 2003 Small business SQL 2005.
My error was "Cannot assign a default value to a local variable." I changed the variable declaration to:

DECLARE @rowCount INT
Set @rowCount = (SELECT COUNT(1) FROM #OrphanedUsers)

DECLARE @i INT
SET @i =1

DECLARE @tempUsername VARCHAR(1000)

Once that fix was in place the code worked like a charm. I've been looking for a quick fix for my SQL users that read and write to the db through ASP.NET stored procs. So in a nut shell, thanks for the code it got me on the right track.

Cheers,
Graham
Julien.Chappel
Julien.Chappel
SSC Rookie
SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)

Group: General Forum Members
Points: 34 Visits: 44
To SSC Veteran,

Could you please read the full extent of my message in particular reference: "The majority of the SQL Server solutions are good and I got a lot of help in taking many of these ideas into my solution.", meaning for the benefit for some "good DBAs" I never use the codes published in this site strait out of the web page. Whatever strongly you feel about your point of you still should remain professional enough not even indirectly imply that who is good DBA and who is not. Among the qualities of a good DBA are accepting others' opinion and if disagree respond with professional courtesy. I don't remember that this site is for even remotely a tool to being personal. As I stated I "fiddled" with it and managed it to run. It it just happens too many too often. In the other day it happened the same with a piece of code (it was a function) which was supposed to return the date of the first day of the week. It in its original code had two bugs:
1./ It returned consistently Tuesday as the first day of the week. I am aware of it that in some country Sunday is the first day of the new week in others is Monday. I newer heard of Tuesday being the first. If there such a calendar or country which uses Tuesday as the first day of the week please someone enlighten me about it.
2./ When I entered as a parameter the date of Monday it returned the previous week's Tuesday the result even after fixing the above Tuesday issue. The bug was in the original code not my fix introduced it. I fixed this as well and I am happily using it in my project to develop a database application.

And there was a period of a few weeks in early this year when unfortunately the majority of the published solutions and codes did not even work and found them so hopless after trying to fix them that I gave up to invest more afford in them. There were some SSIS solutions of which one of them the code and samples were published in an image format not web page text box and instead of the images on the page placeholders were displayed. SQLServerCentral.com is a trusted site in our web server firewall.

And all the others who might directly or indirectly questioning my quality as DBA this is my reply. All my apology to the millions of genuinely professional DBAs and SQL Server developers who are like me registered members of SQLServerCentral.com community have to have to read this. Finally I did not change my opinion that crashing codes should not be published.

Julien.
Julien.Chappel
Julien.Chappel
SSC Rookie
SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)

Group: General Forum Members
Points: 34 Visits: 44
To SSC Veteran,

Could you please read the full extent of my message in particular reference: "The majority of the SQL Server solutions are good and I got a lot of help in taking many of these ideas into my solution.", meaning for the benefit for some "good DBAs" I never use the codes published in this site strait out of the web page. Whatever strongly you feel about your point of you still should remain professional enough not even indirectly imply that who is good DBA and who is not. Among the qualities of a good DBA are accepting others' opinion and if disagree respond with professional courtesy. I don't remember that this site is for even remotely a tool to being personal. As I stated I "fiddled" with it and managed it to run. It it just happens too many too often. In the other day it happened the same with a piece of code (it was a function) which was supposed to return the date of the first day of the week. It in its original code had two bugs:
1./ It returned consistently Tuesday as the first day of the week. I am aware of it that in some country Sunday is the first day of the new week in others is Monday. I newer heard of Tuesday being the first. If there such a calendar or country which uses Tuesday as the first day of the week please someone enlighten me about it.
2./ When I entered as a parameter the date of Monday it returned the previous week's Tuesday the result even after fixing the above Tuesday issue. The bug was in the original code not my fix introduced it. I fixed this as well and I am happily using it in my project to develop a database application.

And there was a period of a few weeks in early this year when unfortunately the majority of the published solutions and codes did not even work and found them so hopless after trying to fix them that I gave up to invest more effort in them. There were some SSIS solutions of which one of them the code and samples were published in an image format not web page text box and instead of the images on the page placeholders were displayed. SQLServerCentral.com is a trusted site in our web server firewall.

And all the others who might directly or indirectly questioning my quality as DBA this is my reply. All my apology to the millions of genuinely professional DBAs and SQL Server developers who are like me registered members of SQLServerCentral.com community have to have to read this. Finally I did not change my opinion that crashing codes should not be published.

Julien.
Rudy Panigas
Rudy Panigas
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3816 Visits: 1325
Julien Chappel,

I'm guessing that you are referring to me when you say "To SSC Veteran".

I'll keep my comments short.

1) My name is not "To SSC Veteran" unless you are directing your comments to ALL SSC Veteran. If you are directing your comments, you should use their name.

2) Not suggesting that you are a "Bad" DBA. Just noticing that Professional (top end) DBAs will take code found here or anywhere, analysis it, try it on there test servers and comment back on their findings. They don't complain about the original code but will help out in making the code work.

3) I still stand in defense of this site and still believe that they don't have the time or man power to test every single code and/or article submitting. It should be up to the author to do their best in testing their code and ensuring accuracy of their articles. Sometimes this doesn't happen. But it's free so really why complain.

4) Remember your options when using a script found here. Either help in making it better for everyone or don't use it.

5) Lastly (as I don't want to make this a story) Positive and constructive comments will help make this site better and will help the author to make better contribution the next time. Help out when you can and if you can at least acknowledge that someone else has at least tried to make a contribution.

Try submitting your own code or article, you will then see that there is always someone who doesn't like it. But that's just the way it goes. I know as I have several articles and script here.

Thanks



logicinside22
logicinside22
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3667 Visits: 1444
Can you post that script if you have modified for Orphaned Users please?

Aim to inspire rather than to teach.
SQL Server DBA
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