June 18, 2009 at 1:59 pm
How do you declare a linked server? Something like this failing example:
DECLARE @linkedserv CHAR;
SET @linkedserv = [srvname];
GO
SELECT * FROM @linkedserv..database.dbo.table;
June 18, 2009 at 2:03 pm
saivko (6/18/2009)
How do you declare a linked server? Something like this failing example:DECLARE @linkedserv CHAR;
SET @linkedserv = [srvname];
GO
SELECT * FROM @linkedserv..database.dbo.table;
You have to add a linked server, not declare it.
sp_addlinkedserver 'myservername'
select * from myservername.database.dbo.table
June 18, 2009 at 2:18 pm
It's already added.... and I can select from it with no problem. I just wanted the wording for the linked server into a parameter for a stored proc.
June 18, 2009 at 2:52 pm
Thanks, getting this though: Incorrect syntax near 'sp_executesql'
June 18, 2009 at 2:57 pm
i guess there must be some syntax error in the query. for sp_executesql, syntax is plain vanilla.
http://msdn.microsoft.com/en-us/library/ms188001(SQL.90).aspx
you may want to have a look at EXECUTE statement too.
http://msdn.microsoft.com/en-us/library/ms188332(SQL.90).aspx
Edit - added url for execute.
June 18, 2009 at 3:05 pm
Thanks, got it now... it wanted an nvarchar rather than a varchar
June 18, 2009 at 3:07 pm
Glad u got it going 🙂
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply