SQLTeam.com | Weblogs | Forums

How to check the License in installed sql

sql2008

#1

I have installed the SQL Server 2008 but not sure whether I installed the licensed version or not. Now how to check the License & license key in the server. Please guide me.


#2

Try this:select PARSENAME(cast(serverproperty(N'ProductVersion') as sysname), 4) Major, PARSENAME(cast(serverproperty(N'ProductVersion') as sysname), 3) Minor, PARSENAME(cast(serverproperty(N'ProductVersion') as sysname), 2) Build, serverproperty(N'ProductLevel') ProductLevel, serverproperty(N'Edition') Edition, serverproperty(N'LicenseType') LicenseType


#3

You can follow this sample query. To know the server property and license type.

SELECT SERVERPROPERTY('LicenseType'), SERVERPROPERTY('NumLicenses')


#4

Hi,

If you need to check your license key run the following code in powershell:

1st - Create the function:

PS C:\Documents and Settings\admin> function GetSqlServerProductKey {
## function to retrieve the license key of a SQL 2008 Server.
param ($targets = ".")
$hklm = 2147483650
$regPath = "SOFTWARE\Microsoft\Microsoft SQL Server\100\Tools\Setup"
$regValue1 = "DigitalProductId"
$regValue2 = "PatchLevel"
$regValue3 = "Edition"
Foreach ($target in $targets) {
$productKey = $null
$win32os = $null
$wmi = [WMIClass]"\$target\root\default:stdRegProv"
$data = $wmi.GetBinaryValue($hklm,$regPath,$regValue1)
[string]$SQLver = $wmi.GetstringValue($hklm,$regPath,$regValue2).svalue
[string]$SQLedition = $wmi.GetstringValue($hklm,$regPath,$regValue3).svalue
$binArray = ($data.uValue)[52..66]
$charsArray = "B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9"
## decrypt base24 encoded binary data
For ($i = 24; $i -ge 0; $i--) {
$k = 0
For ($j = 14; $j -ge 0; $j--) {
$k = $k * 256 -bxor $binArray[$j]
$binArray[$j] = [math]::truncate($k / 24)
$k = $k % 24
}
$productKey = $charsArray[$k] + $productKey
If (($i % 5 -eq 0) -and ($i -ne 0)) {
$productKey = "-" + $productKey
}
}
$win32os = Get-WmiObject Win32_OperatingSystem -computer $target
$obj = New-Object Object
$obj | Add-Member Noteproperty Computer -value $target
$obj | Add-Member Noteproperty OSCaption -value $win32os.Caption
$obj | Add-Member Noteproperty OSArch -value $win32os.OSArchitecture
$obj | Add-Member Noteproperty SQLver -value $SQLver
$obj | Add-Member Noteproperty SQLedition -value $SQLedition
$obj | Add-Member Noteproperty ProductKey -value $productkey
$obj
}
}

2nd - Run the function:

PS C:\Documents and Settings\admin> GetSqlServerProductKey

Computer : .
OSCaption : Microsoft(R) Windows(R) Server 2003, Enterprise Edition
OSArch :
SQLver : 10.4.6241.0
SQLedition : Enterprise Edition
ProductKey : YOUR-PRODUCT-KEY-WILLBE-HERE

For more info you can visit http://mspowershell.blogspot.in/2010/11/sql-server-product-key.html

Regards

Omar L.