Reputation: 520
Does anyone here know how i can determine the version of SQL running on my linked server through use of TSQL statements?
I am running SQL2005 my linked servers are running a mix of sql2000, 2005 and 2008.
Upvotes: 4
Views: 5155
Reputation: 11
You can access @@version through a linked server using OPENQUERY
SET @sql = 'SELECT * FROM OPENQUERY(['+@servername+'],''select @@VERSION'')'
Upvotes: 1
Reputation: 782
One minor nitpick about OPENQUERY is that one cannot use anything other than string literals for both the server and the query.
With EXEC AT you can at least use varchar variables for the query (although it can be a pain to quote the stuff correctly) although not for the server-name:
declare @sql AS varchar(max) = 'SELECT SERVERPROPERTY(''productversion'')' EXEC(@sql) AT MyLinkedServer
I assume this is just a parser limitation rather than some deliberate limitation in the design.
Upvotes: 5
Reputation: 30912
select * from openquery(MyLinkedServer,'SELECT SERVERPROPERTY(''productversion'')')
Works
Upvotes: 14
Reputation: 5039
SELECT @@VERSION
Returns a string detailing the version of the server.
Upvotes: 0