views:

276

answers:

4

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.

A: 

SELECT @@VERSION

Returns a string detailing the version of the server.

HollyStyles
@@Version does only work on the local server, not on the linked server
Coentje
Same with SERVERPROPERTY('productversion')
Coentje
+2  A: 
select * from openquery(MyLinkedServer,'SELECT SERVERPROPERTY(''productversion'')')

Works

SWeko
Correct, this does work perfect. Never thought of openquery.Thanx
Coentje
+3  A: 

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.

Paul Harrington
+1 because this answer is more versatile and can be used in a more flexible way when needed
Coentje
I got so used to openquery, I didn't ever bother to try EXEC ... ATThis is way more flexible for calling server procs and parametrized queries. However, for simple things, openquery is more straight-forward.
SWeko
A: 

Also exec master..xp_msver

Madhivanan