Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,576 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,893 people online right now. Registration is fast and FREE... Join Now!




Alter Login Procedure

 
Reply to this topicStart new topic

Alter Login Procedure

Rating  5
the_freedom
28 Sep, 2008 - 11:02 AM
Post #1

New D.I.C Head
*

Joined: 12 Sep, 2008
Posts: 8


My Contributions
Hi, I'm trying to create a SQL Stored Procedure to change the login password...
jut like that:

CODE

create procedure sp_altLogin
@pasword varchar(20)
as
begin
    ALTER LOGIN [<loginname>] WITH password = @password, DEFAULT_DATABASE=[<DBName>], DEFAULT_LANGUAGE=[Português (Brasil)];
    EXEC master..sp_addsrvrolemember <loginname>,'sysadmin';
    EXEC sp_addrolemember 'db_owner', <loginname>;
end


And it's not working, they program sent the message:
"Msg 102, Level 15, State 1, Procedure sp_altLoginSindico, Line 5
Incorrect syntax near '@password'."

Thanks

Ps: Please forgive any mistake on the post, I'm from Brazil and I haven't completed my english course yet.

User is offlineProfile CardPM
+Quote Post

eclipsed4utoo
RE: Alter Login Procedure
1 Oct, 2008 - 04:46 AM
Post #2

D.I.C Regular
Group Icon

Joined: 21 Mar, 2008
Posts: 363



Thanked: 19 times
Dream Kudos: 25
My Contributions
you should probably try to spell password correctly as the parameter of the "sp_altLogin" procedure. you spelled it "@pasword", yet you are trying to reference "@password".
User is offlineProfile CardPM
+Quote Post

the_freedom
RE: Alter Login Procedure
1 Oct, 2008 - 05:48 AM
Post #3

New D.I.C Head
*

Joined: 12 Sep, 2008
Posts: 8


My Contributions
Hmmm
sorry for that mistake, it happened when I was translating the variables to english.
I've checked the spell now and it's correct but the same mistake is reported.
It's not recognizing my variablI tried to do this way
CODE
[...] with password = ''+@password

this way I have this error:
"Msg 102, Level 15, State 1, Procedure sp_altLogin, Line 5
Incorrect syntax near '+'."
and I tried this way too
CODE
[...] with password = '@password'

it works but the password is changed to "@password"

Any ideia about how to make my variable be recognized in the alter login statement?
User is offlineProfile CardPM
+Quote Post

the_freedom
RE: Alter Login Procedure
1 Oct, 2008 - 06:27 AM
Post #4

New D.I.C Head
*

Joined: 12 Sep, 2008
Posts: 8


My Contributions
I found an alternative

CODE
create Procedure SP_altLogin
@old varchar(20), @new varchar(20),@login varchar(20)
as
begin
    exec sp_password @old , @new , @login
end


It works perfectly for me
I wish this topic helps others =D
smile.gif

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 12:11AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month