April 24, 2002 at 7:38 pm
I am having a script which creates objects in a database i.e. it has create table, view etc. It should be run as say 'user1' and 'user1' is the dbo.
But users usually make the mistake of running it as 'sa' and this spoils the purpose of it.
How can I prevent it? I want to throw error and if possible EXIT SQLQuery Analyzer.
The users always use SQLQuery Analyzer.
Please give me a suggestion and I have not tried it in iSQL for the above mentioned reason.
Thanks,
NeoNash
April 24, 2002 at 7:43 pm
Really you cannot do this except possibly with an application permission but have never tried so cannot say. I suggest change the SA password and not let anyone have it as they can cause a lot of damage with that kind of access anyway.
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
April 25, 2002 at 1:45 pm
I need to add the scenario.
I generate the script for this application and my clients install on their database servers. So, the question is not the password control but its wrong usage.
April 25, 2002 at 4:05 pm
Ok it is not the login problem but the fact they use the script under the sa login. Since it is a script then try this at the begining
if SYSTEM_USER = 'sa'
BEGIN
RAISERROR('This script must be run from a user account, please exit and login the proper account.', 16, -1)
RETURN
END
That is as close to what you state as I can see how to get.
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply