Does anyone here know how i can determine the version of SQL running on my linked server through use of TSQL statements?
有谁知道我如何通过使用TSQL语句确定在我的链接服务器上运行的SQL的版本?
I am running SQL2005 my linked servers are running a mix of sql2000, 2005 and 2008.
我正在运行SQL2005我的链接服务器正在运行sql2000,2005和2008的混合。
5 个解决方案
#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.
关于OPENQUERY的一个小问题是,对于服务器和查询,除了字符串文字之外不能使用任何其他东西。
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:
使用EXEC AT,您至少可以使用varchar变量进行查询(尽管引用正确的内容可能很麻烦),但不是服务器名称:
declare @sql AS varchar(max) = 'SELECT SERVERPROPERTY(''productversion'')' EXEC(@sql) AT MyLinkedServer
在MyLinkedServer声明@sql AS varchar(max)='SELECT SERVERPROPERTY(''productversion'')'EXEC(@sql)
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
您可以使用OPENQUERY通过链接服务器访问@@ version
SET @sql = 'SELECT * FROM OPENQUERY(['+@servername+'],''select @@VERSION'')'
SET @sql ='SELECT * FROM OPENQUERY(['+ @ servername +'],''select @@ VERSION'')'
#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.
关于OPENQUERY的一个小问题是,对于服务器和查询,除了字符串文字之外不能使用任何其他东西。
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:
使用EXEC AT,您至少可以使用varchar变量进行查询(尽管引用正确的内容可能很麻烦),但不是服务器名称:
declare @sql AS varchar(max) = 'SELECT SERVERPROPERTY(''productversion'')' EXEC(@sql) AT MyLinkedServer
在MyLinkedServer声明@sql AS varchar(max)='SELECT SERVERPROPERTY(''productversion'')'EXEC(@sql)
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
您可以使用OPENQUERY通过链接服务器访问@@ version
SET @sql = 'SELECT * FROM OPENQUERY(['+@servername+'],''select @@VERSION'')'
SET @sql ='SELECT * FROM OPENQUERY(['+ @ servername +'],''select @@ VERSION'')'