Hi,
I have formulated the following query which works fine and links to Server1 and does the computation;
SELECT TOP (100) PERCENT dbo.TblAuto_coll.Prac_no
FROM dbo.TblAuto_coll INNER JOIN
Server1.[GPRD-RCT].dbo.Practice AS Practice ON dbo.TblAuto_coll.Prac_no = Practice.Practicecode
WHERE (dbo.TblAuto_coll.col_status <> 'S')
ORDER BY dbo.TblAuto_coll.Prac_no
Ofcourse, I addlinked server as follows:
Use master
Go
EXEC sp_addlinkedserver
'Server1',
N'SQL Server'
GO
Now, I tried for another server same procedure and changed the query to;
SELECT TOP (100) PERCENT dbo.TblAuto_coll.Prac_no
FROM dbo.TblAuto_coll INNER JOIN
Server2.[GPRD-RCT].dbo.Practice AS Practice ON dbo.TblAuto_coll.Prac_no = Practice.Practicecode
WHERE (dbo.TblAuto_coll.col_status <> 'S')
ORDER BY dbo.TblAuto_coll.Prac_no
I receive the error;
SQL Execution Error
Error Source: .Net SqlClient Data Provider
Error Message: Incorrect syntax near '-'
Why do I receive the error and the database name - GPRD-RCT exists in Server2 too, with the table Practice.
N/B: when I execute the query the line of code changes from
Server2.[GPRD-RCT].dbo.Practice AS Practice
to
Server2.GPRD - RCT.dbo.Practice AS Practice
Thank you