问题
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.
回答1:
select * from openquery(MyLinkedServer,'SELECT SERVERPROPERTY(''productversion'')')
Works
回答2:
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.
回答3:
SELECT @@VERSION
Returns a string detailing the version of the server.
回答4:
Also you can try:
exec master..xp_msver
回答5:
You can access @@version through a linked server using OPENQUERY
SET @sql = 'SELECT * FROM OPENQUERY(['+@servername+'],''select @@VERSION'')'
来源:https://stackoverflow.com/questions/949533/determine-sql-server-version-of-linked-server