1

I am trying to alter credentials using this SQL query:

ALTER CREDENTIAL credential_name WITH IDENTITY = 'identity_name'
  [ , SECRET = 'secret' ]

And the issue is that my credential_name has a space in it. So that would make my query look something like:

ALTER CREDENTIAL HCC SQL WITH IDENTITY = 'username', SECRET = 'password';

Running this, I get these errors:

Msg 102, Level 15, State 1, Line 4
Incorrect syntax near 'SQL'.

Msg 319, Level 15, State 1, Line 4
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.

So I was wondering if there is a way to skip the space in this query?

Or would I have to change my credential_name to something with no spaces?

1 Answer 1

2

As with most entity names in SQL Server, you can use square brackets around your credential's name:

ALTER CREDENTIAL [HCC SQL] WITH IDENTITY = 'username', SECRET = 'password';

This works in my local instance of SQL Server 15.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.