Good morning: I've recently moved offices and I was assigned a new userID and profile. My dilemma is that when logging into SSMS the stored procedures I've created under my old userID are no longer in the list.
How/where would I be able to retrieve those? I'll need to have server admins allow me access to my old login, if that's what I need to do? And then how do I bring them over to my new userID?
I meant to add that I first noticed this when I went to call a stored procedure from when refreshing a data table in Excel and it spit out an error.
Thanks in advance for all the suggestions/ input!
Robin
the server admins got back to me, and it was a matter of updating my permissions and creating a new login with dbo on the database with my new userID and ADLogon. After they performed that change, I was able to see all objects and run commands. Life is good!
Related
Im working on an azure database just adding a couple of Stored Procedures and just making sure the program I'm building with it in .NET is all aligned properly.
I'm not going to go into the Stored Procedure itself nor the Program I'm developing because I don't believe the problem is there, I have a Development program and database which is using the exact same code and they work fine, I'm using Microsoft's SQL Server Management Studio to handle everything on the servers side.
The only difference to the current setup is that I myself scripted a bunch of the Stored procedures and a single View of a table that I did not create....(I did not create the table, but I made a view for it which is a slightly different format)
The person creating most of these databases and table is one of the database administrators I guess (not Microsoft, but an employee of the company using their services), I on the other hand am a freelance programmer and I'm guessing I have somewhat limited access to the server (limited credentials).....although it's allowing me to do more or less anything I need to do like creating SP's etc.
My current (and only problem) is a single stored procedure that runs through without an error does not update the table (the table i did not create) the Stored Procedure just inserts a couple of records and then deletes a record from the same table.......
It deletes the record just fine but for some reason the INSERT doesn't insert anything.
Again, this works fine on another Development database and the programs are sending the exact same strings but this new database just doesn't want to play along.....
Could this be a permission problem I'm having between my stored procedure and the table I did not create?
I would love to dump this onto the admin guy (and already did but he dumped it back on me haha) so I just want to be sure I'm not wasting his time....... and give him something solid to go on.
Thanks for your help Paul S.
I want to get the details of the Deleted Stored Procedures and Functions
Also i want to get the info like when it was created & removed in DB.
Please guide me.
Thanks in Advance...
You can see when procedures and functions were created by looking at the CREATE_TIME column tables in the system catalog like SYSCAT.PROCEDURES and SYSCAT.FUNCTIONS.
You will have no way of knowing when these objects were dropped unless you enable auditing within the database (and review the audit logs to find instances of DROP PROCEDURE or DROP FUNCTION).
I am developing an MVC 4 application. I am working on the membership authentication and profile module, and I am a bit confused.
I am confused because it seems that there ar TWO sets of Authorization/Profile modules working behind the scenes:
Short Version
There are TWO sets of tables for Authorization: one created when you create a new MVC 4 Internet application
The second is created when you run aspnet_regsql.
Data is saved and feteched from the two sets in a confusing way.
How are the two sets related:
What is saved where?
Why are Users created in the two sets?
etc.
Long Version
Set 1
I created a new MVC 4 Internet project. It was generated with the ability to register users and create roles. The database that was automatically generated contained the following tables: Users, Roles, UserInRoles, Memebership, Profiles.
There were no stored procedures.
The Authorization worked OK: Users data and roles were correctly saved in Users, Roles and UserInRoles tables.
Set 2
I then moved on tp add Profile for the site users. I followd Joel's answer. When running the code hit this line:
AccountProfile.CurrentUser.FullName = "Snoopy";
I received this error:
Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.
I ran aspnet_regsql against the database created earlier, and the expected set of aspnet_ tables and stored procedure was created.
Tested my code again.
This time it worked OK and the profile property was saved OK to the aspnet_Profile table (whic is to be expected).
In the next step I created a new user. The user was created in BOTH Users and aspnet_Users tables (with different UserId values) -- please see here picture 1
Added the property FullName=Snoopy to his profile.
Running Membership.GetUser().ProviderUserKey returns the UserId from table Users.
Running AccountProfile.CurrentUser.FullName returns "Snoopy".
Please see here picture 2.
This very surprising because it means that somehow the system knows how to relate a record from table Users to a record in table aspnet_Profile where the UserId field is from table aspnet_users.
BTW, I verified that table Profiles is empty so the value was not feteched from there.
So what is going on here?
Is this behavior the expected behavior?
Or is Jole's answer wrong in the sense that there some other (better?) way to implement Profile in an MVC 4 application, and what I did is to throw a wrench in the works?
You should probably use one or the other. Here's a recent post to help you decide:
http://weblogs.asp.net/jgalloway/archive/2012/08/29/simplemembership-membership-providers-universal-providers-and-the-new-asp-net-4-5-web-forms-and-asp-net-mvc-4-templates.aspx
I'm contemplating using AFTER INSERT, DELETE, UPDATE Triggers to capture changes to one of my databases. One thing I want is to capture name of the user who made the change.
Since I'm using a dedicated SQL account to connect to the database (from ASP.NET MVC), I don't believe SUSER_SNAME() will provide accurate information to me.
Is there anyway for me to feed in the username from ASP.NET MVC side to the trigger?
ASP.NET side is configured for Windows Authentication against Active Directory.
Take a look at Set Context_Info. I've used this successfully in the past when auditing and using sql authentication. The idea is that you set the in the context the logged on user, then in the DB Trigger you retrieve this info from the context and store it in the DB. If you forget to set the user in the context, you can always fall back to suser_name (although, not very useful for auditing, but can be useful when making changes directly in SSMS). Google "Audit Trail Set Context_Info" and you will find some examples.
Like this one and this other one
You could use Thread.CurrentPrincipal to get the Windows Account and pass this as a parameter to your queries, and therefore, available to Triggers.
var userName = Thread.CurrentPrincipal.Identity.Name;
In creating a new ASP.NET MVC application, I have an issue with the approach I'm using to store user-created data for temporary users who have yet to create an account which I then try to convert to a real user. That probably doesn't make much sense, so let me explain:
A visitor to the site can enter profile settings before being made to register with a username, password, etc.
I'm creating database entries via LINQ to SQL for a new user in this case, using the Request.AnonymousID value as a temporary username.
When the user chooses to register, I need to 'switch over' the relevant database records to use the newly entered username instead of the temporary one.
The problem is that when I try to update the record I can't because the username is the primary key, so I'm forced to delete the record and add a new one...
I can probably persevere with this, but I think I might just be going about this in completely the wrong way and wondered if anyone could suggest a better way to allow visitors to store information before they've registered and have that carry over when they do.
I know about profiles but want the profile information to be available to other visitors. I also know that I can create an anonymous profile but it seems like I should be able to keep the data model out of the web.config file.
I would suggest having an independent primary key for the table with your custom user data.
And then have fields like RefAnonymousId and RefUserId to relate that user data to the anonymous user and the registered user, respectively.
For example:
TABLE UserData
(
UserDataID int IDENTITY(1,1) PRIMARY KEY,
RefAnonymousId uniqueidentifier,
RefUserId uniqueidentifier,
... (data fields),
(maybe also unique keys on RefUserId and RefAnonymousId)
)
That way you will also be able to identify the user when the user is logged out and maybe automatically log the user in...