I am trying to create a stored procedure to Call ALTER LOGIN based on the the username passed in. However, the Alter login statement chokes on any parameter. Is there a way I can alter sql logins from a web form ?
I try the following and it bombs
ALTER
LOGIN @.LoginNameWITH PASSWORD= @.PasswordBut this works
ALTER LOGIN 'TestUser' WITH PASSWORD = '123test'
I guess the alter login statement does not work with Parameters.
Any thoughts ?
EXEC('ALTER LOGIN ' + @.loginName + ' WITH PASSWORD= ' + @.Passrowd)
|||
I get an error when I set the password. Should I add double quotes to the password ?
|||yes you are right. You need to escape the quotes..Sorry about that.
EXEC('ALTER LOGIN ' + @.loginName + ' WITH PASSWORD= ''' + @.Passrowd + '''')
|||Perfect Thanks!
No comments:
Post a Comment