Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
fralo
Posting Yak Master
161 Posts |
Posted - 2009-08-27 : 12:48:32
|
| Having set up a linked server I can not reference the Server Name in this query. It's not recognized.set @OFFNUM = (SELECT count(*) FROM Server2.EMPMAST.DBO.EMPMAST) |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2009-08-27 : 13:31:18
|
| Are you sure that SERVER2 is the correct name for the linked server? What error message do you get? |
 |
|
|
fralo
Posting Yak Master
161 Posts |
Posted - 2009-08-27 : 14:03:56
|
| Well, the real name is ESO-CAD. I just didn't wanna post the name on this site but I don't guess it matters. I checked my Linked Servers under Management Studio, and it's correct.I hope i did everything correct when I created the linked server. |
 |
|
|
fralo
Posting Yak Master
161 Posts |
Posted - 2009-08-27 : 14:09:48
|
| The query is actuallyset @OFFNUM = (SELECT count(*) FROM ESO-CAD.EMPMAST.DBO.EMPMAST)"Incorrect syntax near '-'." |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-08-27 : 14:12:33
|
| set @OFFNUM = (SELECT count(*) FROM [ESO-CAD].EMPMAST.DBO.EMPMAST)Jim |
 |
|
|
fralo
Posting Yak Master
161 Posts |
Posted - 2009-08-27 : 14:20:21
|
| No work. [ESO-CAD].EMPMAST.DBO.EMPMAST is underlined with error Invalid object name. |
 |
|
|
fralo
Posting Yak Master
161 Posts |
Posted - 2009-08-28 : 11:57:42
|
| I've researched a little bit and have discovered the OPENQUERY rowset function. No syntax errors occur here. Hope it's correct.set @OFFNUM = (SELECT * FROM OPENQUERY([ESO-CAD], 'SELECT COUNT(*) FROM EMPMAST.DBO.EMPMAST') |
 |
|
|
|
|
|