I hope I posted this in the correct forum....
I am developing a program in .Net 2005 that gets a list of available sql servers. Given that there are many different types of SQL servers, i am trying to figure a way to determine the specific version(s) that are on a given machine without forcing a separate login screen. This will help to make the connection string(s) more detailed and accurate and me to make sure the correct keyword sets are available between the various platforms. Can anybody help me with this?
Since you are using .NET 2005 you can use SMO to get the version of an instance of SQL. The below in is visual basic, but the same functionality is available in C#.Code Snippet
ImportsMicrosoft.SqlServer.Management.Smo Dim local As Server Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then 'create the Server SMO pointed to the local SQL Server
local =New Server("(local)") Dim version As String
version = local.Information.Version.ToString()End Sub
That certainly helps a bit. I am noticing that alot of the servers do not produce version info though. Could that be due to permissions or do older versions (like SQL 7) just not produce version info? Also, is there any easy way/readily available way to parse down the version so that I can say what service packs, etc they are on like you can the OS on a computer? So instead of version 9.x.xxx I can say SQL 2005 SP1 Build X??
I believe that this is version related and attempted to get the reference, but could not locate it.
As far as pre-built way to provide a user friendly version name I am not aware of any property that is provided in this method. You could use a Case statement and compare a build list to the specific build number and provide the user friendly name. I would Suggest using a function that would return the user friendly name based on the build number. This sounds buredensom, but I have included hyperlinks that have the builds for 2000, 2005, and 2008 which also provide a downloadable csv file. Hope this helps!
SQL 2005 build list:
SQL 2008 build list
SQL 2000 build list
I will complete your code ( but as i have only Sql Server 2008 and VS 2008 SP1, you will need to adapt this code for Sql Server 2005 )
and the result in the .txt file ( used by the StreamWriter )
To be run , this code needs some special added references but it is working versus Sql Server 2005
Microsoft.SqlServer.Management.Sdk.dll for example
I hope that code will help you
Have a nice day
Please remember to click 'Mark as Answer' on the post that helped you. Unmark if it provides no help