Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem Forcing Password Change
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01396746
Message ID:
01396752
Views:
43
A password shoul be enclosed in single quotes not square brackets
SET @SqlStatement = N'ALTER LOGIN [' + @LoginName + '] WITH PASSWORD = ''' + @Password + ''' UNLOCK MUST_CHANGE'
>I'm sure I've got something wrong here, but I just don't know what it is:
>
>
>
>USE [master]
>GO
>
>DECLARE @LoginName VARCHAR(20)
>DECLARE @Password VARCHAR(20)
>DECLARE @SqlStatement NVARCHAR(MAX);
>
>SET @LoginName = 'TestABC'
>SET @Password = 'testabc'
>
>
>--ALTER LOGIN TestABC WITH CHECK_EXPIRATION = ON
>--ALTER LOGIN TestABC WITH PASSWORD = 'testabc' UNLOCK MUST_CHANGE
>
>SET @SqlStatement = N'ALTER LOGIN [' + @LoginName + '] WITH CHECK_EXPIRATION = ON'
>EXECUTE (@SqlStatement);
>
>SET @SqlStatement = N'ALTER LOGIN [' + @LoginName + '] WITH PASSWORD = [' + @Password + '] UNLOCK MUST_CHANGE'
>EXECUTE (@SqlStatement);
>
>
>It errors with "Syntax error near Password"
>
>Thanks
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform