Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


sp_addlinkedserver not able to execute with other command line


sp_addlinkedserver not able to execute with other command line

Author
Message
yun83
yun83
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 11
Hi there,

I am barely new with T-SQL and trying to link to the other server database with sp_addlinkedserver.

I am able to make connection with only executing the sp_addlinkedserver and then pull the data from the remote server.

But, when I put everything together, the sp_addlinkedserver stops working and keep on prompt me that the target server is not on the sys.servers.

sp_addlinkedserver also will not work if it were executed from the stored procedure?

Working:

EXECUTE sp_addlinkedserver
@server = 'pHpnng',
@srvproduct = '',
@provider = 'SQLNCLI',
@datasrc = 'pHpnng',
@provstr = 'DRIVER=SQL Server;SERVER=pHpnng;UID=sa;PWD=Spm2009!;'
END

SELECT * FROM sys.servers WHERE data_source = 'pHpnng'




Not Working:
(With the additional line will cause everything to stop working and the 'pHpnng' will not appear on the sys.servers at the end of the execution)

EXECUTE sp_addlinkedserver
@server = 'pHpnng',
@srvproduct = '',
@provider = 'SQLNCLI',
@datasrc = 'pHpnng',
@provstr = 'DRIVER=SQL Server;SERVER=pHpnng;UID=sa;PWD=Spm2009!;'
END

SELECT * FROM [pHpnng].[OTestSystemDB].[dbo].[ListName]



This only works if I ran the 1st code, then run the "SELECT * FROM [pHpnng].[OTestSystemDB].[dbo].[ListName]" seperately.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search