Need product information

I am looking for a way to find production information for sql server. I am looking for @@version but I don't want to run @@version and parse this. Would prefer to get this from serverproperty ('correctpropertyname') 

I want everything before the - (dash) 

 

Microsoft SQL Server 2008 (SP3) - 

 

 

 

 

 

Parents
No Data
Reply
  • For those interested in the SMO version of the above, here is the approximate code:

    [void][Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO")
    $sqldetails = @()
    $sqlservers = "sqlserver","sql2005express\sqlexpress"

    foreach ($sqlserver in $sqlservers) {
    $server = New-Object Microsoft.SqlServer.Management.Smo.Server $sqlserver

    switch ($server.VersionMajor) {
    9 { $version = 2005 }
    10 {
    $version = 2008
    if ($server.VersionMinor -eq 50) { $version = "2008 R2" }
    }
    11 { $version = 2012 }
    12 { $version = 2014 }
    13 { $version = 2016 }
    }

    $sqldetails += [PSCustomObject]@{
    ServerName = $server.DomainInstanceName
    Product = "SQL Server $version"
    ProductVersion = $server.ResourceVersion
    ProductLevel = $server.ProductLevel
    Edition = $server.Edition
    EngineEdition = $server.EngineEdition
    }

    }

    $sqldetails

    The output looks like this

     

Children
No Data