chipiu3001
Thành viên hoạt động



- Tham gia
- 22/8/15
- Bài viết
- 105
- Được thích
- 15
Chào các anh chị.
Em muốn thay đổi Password cho người dùng đăng nhập SQL server bằng userform excel.
Trong Sql management studio:
Chạy lệnh ALTER LOGIN [Username] WITH PASSWORD = 'Pwmoi' OLD_PASSWORD = 'Pwcu';
Lệnh này thay đổi PW OK
Em chuyển lệnh này thành Procedure stored:
CREATE proc ChangePW
@username VarChar (50),
@OldPass VarChar (50),
@NewPass VarChar (50)
AS
BEGIN
ALTER LOGIN @username WITH
PASSWORD = @NewPass
OLD_PASSWORD = @OldPass
END
Chạy thì báo lỗi
"
Msg 102, Level 15, State 1, Procedure ChangePW, Line 7
Incorrect syntax near '@username'.
Msg 319, Level 15, State 1, Procedure ChangePW, Line 7
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon. "
Vậy mọi người xem giúp em lỗi do đâu và sửa giúp em với. Có tạo được Procedure stored thì mới làm các bước tiếp theo trên userform được.
Hoặc mọi người chỉ em cách thay đổi PW Sql server từ userform excel với ạ ( Userform gồm 3 textbox : User_name, Pwold, Pwnew)
Em cảm ơn mọi người nhiều
Em muốn thay đổi Password cho người dùng đăng nhập SQL server bằng userform excel.
Trong Sql management studio:
Chạy lệnh ALTER LOGIN [Username] WITH PASSWORD = 'Pwmoi' OLD_PASSWORD = 'Pwcu';
Lệnh này thay đổi PW OK
Em chuyển lệnh này thành Procedure stored:
CREATE proc ChangePW
@username VarChar (50),
@OldPass VarChar (50),
@NewPass VarChar (50)
AS
BEGIN
ALTER LOGIN @username WITH
PASSWORD = @NewPass
OLD_PASSWORD = @OldPass
END
Chạy thì báo lỗi
"
Msg 102, Level 15, State 1, Procedure ChangePW, Line 7
Incorrect syntax near '@username'.
Msg 319, Level 15, State 1, Procedure ChangePW, Line 7
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon. "
Vậy mọi người xem giúp em lỗi do đâu và sửa giúp em với. Có tạo được Procedure stored thì mới làm các bước tiếp theo trên userform được.
Hoặc mọi người chỉ em cách thay đổi PW Sql server từ userform excel với ạ ( Userform gồm 3 textbox : User_name, Pwold, Pwnew)
Em cảm ơn mọi người nhiều