How can I determine SQL Server licensing mode within stored proc?

  • Is there any method (T-SQL, extended stored proc, ...) that I can determine the licensing mode for a particular instance of SQL Server?  I was hoping that sp_server_info would work, but it doesn't appear that licensing mode is one of the supported attributes.

    We would like to deploy our schema to client server(s), but would like to be able to determine (from within our application), what the current license is for that particular instance.  We would like to know whether its user CALs, device CALs, or processor - and how many CALs or processors are licensed.

    Any suggestions?

  • This was removed by the editor as SPAM

  • Try the below script....if you are using named instances you'll need to change the registry location....

     


    CREATE TABLE #LICENSE_RESULTS (LICENSETYPE VARCHAR(25), LICENSECOUNT INT)

    DECLARE @MODE VARCHAR(25)

    DECLARE @testmode int

     EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE',

       @key='Software\Microsoft\Microsoft SQL Server\80\MSSQLLicenseInfo\MSSQL8.00',

       @value_name='Mode',

       @value=@testmode OUTPUT

     --SELECT @testmode

    IF @testmode = 1

     BEGIN

      SET @mode = 'Per Seat'

     END

    ELSE

     BEGIN

      SET @mode = 'Per Processor'

     END

    DECLARE @testlimit int

     EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE',

       @key='Software\Microsoft\Microsoft SQL Server\80\MSSQLLicenseInfo\MSSQL8.00',

       @value_name='ConcurrentLimit',

       @value=@testlimit OUTPUT

     --SELECT @testlimit

    INSERT INTO #LICENSE_RESULTS VALUES (@MODE, @TESTLIMIT)

    SELECT * FROM #LICENSE_RESULTS



    Shamless self promotion - read my blog http://sirsql.net

  • SELECT   CONVERT(char(20), SERVERPROPERTY('NumLicenses'))

    --returned "PER_PROCESSOR" in my cluster

    SELECT   CONVERT(char(20), SERVERPROPERTY('LicenseType'))

    --returned "4"   in my 4 processor cluster

    -- Look up SERVERPROPERTY in BOL

  • This query was just what I needed.

    Thanks!

  • Just be aware of this:

    http://support.microsoft.com/default.aspx?scid=KB;en-us;291332

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply