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 ««12

Fix all orphaned users in a database Expand / Collapse
Author
Message
Posted Wednesday, November 24, 2010 1:28 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, January 26, 2011 8:56 AM
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
Post #1026166
Posted Wednesday, November 24, 2010 4:03 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, April 18, 2011 8:08 PM
Points: 10, 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.
Post #1026246
Posted Wednesday, November 24, 2010 4:06 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, April 18, 2011 8:08 PM
Points: 10, 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.
Post #1026248
Posted Friday, November 26, 2010 7:27 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: 2 days ago @ 8:18 AM
Points: 318, Visits: 1,128
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



Post #1026777
Posted Thursday, December 1, 2011 2:25 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: 2 days ago @ 7:39 AM
Points: 321, Visits: 1,294
Can you post that script if you have modified for Orphaned Users please?

Aim to inspire rather than to teach.
SQL Server DBA
Post #1215011
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse