i am trying to run a query in another server and need to specify it in the select statement but the server name has got an '-' in it, like server-name. this is producing the error in the title. How can i fix it?
Asked
Active
Viewed 1.7k times
3 Answers
24
Use square brackets []
around the servername:
select *
from [server-name].[db-name].[schema-name].[table-name]

Andomar
- 232,371
- 49
- 380
- 404
0
I came across an SQL query on some website, which was supposed to be correct, but I was getting the same error. It appears, that some websites format text and swap the minus sign with some Office-like abomination.
Incorrect minus character: –
Correct one: -

Human programmer
- 408
- 4
- 11
0
I also came across this error when I work with spring boot and MSSQL db. We may get this error, when we did not define the schema and the table name correctly. I have included the below schema name with square brackets in the model class and I could overcome this issue.
@Table(name = "FIELDS_PARAM",schema = "[sample-schema]")

Senthuran
- 1,583
- 2
- 15
- 19