Click here to Skip to main content
14,356,134 members
Rate this:
Please Sign up or sign in to vote.
Hello everyone,

I have two machines which are connected with LAN and i have SQL-2008 on both machine and i have linked both the SQL server by using this stored procedure

Exec sp_addlinkedserver
@srvproduct='SQLServer OLEDB Provider',

now i need to query this server database, from another machine.
I have written this

select * from CMSSERVER\SQLEXPRESS.CMS_Syllabus.dbo.Admin_Details

but the error i am getting is incorrect syntax near '\'

Please tell me am i doing this correctly , or give me some other idea to implement this.

I need to fire query on other linked server from the one which i have, please explain me how to make it..

Really stucked up..

Thanks in advance.
Krunal Panchal
Updated 2-Oct-19 21:09pm
LaxmikantYadav 27-Apr-11 5:39am
Try This,

select * from CMSSERVER\\SQLEXPRESS.CMS_Syllabus.dbo.Admin_Details
Rate this:
Please Sign up or sign in to vote.

Solution 1

Try this
select * from [CMSSERVER\SQLEXPRESS].CMS_Syllabus.dbo.Admin_Details
[no name] 27-Apr-11 11:33am
Your thing worked but i am getting error of Named Pipes, enabled named pipes and tcp/ip on both machine ..
please help me out what to do in this case

Krunal Panchal
Rate this:
Please Sign up or sign in to vote.

Solution 3

You should try OPENQUERY if you're workin with linked servers
select * from OPENQUERY([CMSSERVER\SQLEXPRESS], 'select * from CMS_Syllabus.dbo.Admin_Details')
Maciej Los 10-Jun-15 9:24am
Why do you post an answer for such old question?
CHill60 10-Jun-15 10:14am
OpenQuery was suggested over 3 years ago. There was no point in this post
Bohdan Stupak 12-Jun-15 6:50am
I was googling for openquery syntax and found this question. So when I've finished my research I've diceded also to post answer here. Don't forget that questioner is not only person, who is ineterested in finding correct answer. Also there are many people who just google around.
CHill60 12-Jun-15 8:08am
I agree. But you have brought nothing new - OpenQuery was suggested in Solution 2 over 3 years ago. You are duplicating information that was already available on this post. As I said, a pointless exercise, and one that has attracted down votes

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100