So my problem:
I have to query Linked servers for Version number and evaluate it against another. This is going to be used in a SP that will do other stuff, not related to this issue. Also, the environment has MSSQL 2000 up to MSSQL 2008R2. I specifically want to identify the MSSQL 2000 servers, they are my issue in the next phase of my project.
My solution (but not it seems):
I have created the following Dynamic Query to hit the Linked servers:
DECLARE @ServerName AS VARCHAR(50)
SET @ServerName = <YOURSERVERNAME>
DECLARE @Sql AS VARCHAR(100), @Result AS VARCHAR(10)
SET @Sql = 'SELECT * FROM OPENQUERY([' + @ServerName + '], ' + '''' + 'SELECT SERVERPROPERTY(' + '''' + '''' + 'productversion' + '''' + '''' + ')' + '''' + ')'
EXECUTE (@Sql) OUT, @RESULT OUTPUT
IF @Result <= '9.00.1399.06'
The first declare parameter @ServerName and PRINT statements are just to test my conditional results. @ServerName will be generated from a CURSOR later. I'm sure my issue has to do with the OUT and OUTPUT parameters, but I just can't seem to get my head unlocked from this one. Any help is greatly appreciated!
Frederick (Fred) J. Stemp, Jr.
Database Administrator / Database Developer
Dealer Funding, LLC
'...if they take my stapler then I'll set the building on fire...'