I am trying to run the following in SSMS:
IF NOT EXISTS (SELECT loginname FROM master.dbo.syslogins
WHERE name = 'test.'user')
BEGIN
CREATE LOGIN [test.'user]
WITH PASSWORD = 'test'123',
DEFAULT_DATABASE = TestDB,
DEFAULT_LANGUAGE = [us_english],
CHECK_EXPIRATION = OFF,
CHECK_POLICY = OFF
END
It gives an error:
Unclosed quotation mark after the character string.
This is because the password has a single quote. How can i escape the password and username to fix this ?