Uma Sankar Redd...'s profileSankar Reddy's sql spacePhotosBlogListsMore Tools Help

Blog


    September 23

    Database Internal version; Create Version and Current Version

    SQL Server has versions, editions, service packs, compatibility levels and Internal versions. Most of the people know about the first 4 and if you are wondering about what is the database internal version then you should look at Database Version vs Database Compatibility Level post by Jonathan Kehayias and Technet Q&A article by Paul Randal.

    Here is a script I wrote to look at what’s the create and current internal database version of all databases. This might be handy if you have to look at multiple databases on different servers.

    CREATE TABLE #version ( 
        VersionID INT
        , VersionName VARCHAR(255)
    ) 
    
    INSERT #version
        SELECT 515, 'SQL Server 7.0' UNION ALL
        SELECT 539, 'SQL Server 2000' UNION ALL
        SELECT 611, 'SQL Server 2005, VARDECIMAL disabled' UNION ALL
        SELECT 612, 'SQL Server 2005, VARDECIMAL enabled' UNION ALL
        SELECT 655, 'SQL Server 2008' UNION ALL
        SELECT 660, 'SQL Server 2008 R2' 
    
    CREATE TABLE #DBCC ( 
        ParentObject VARCHAR(255)
        , [Object] VARCHAR(255)
        , Field VARCHAR(255)
        , [Value] VARCHAR(255) 
    ) 
    
    CREATE TABLE #DBCCResults (
        ServerName VARCHAR(255)
        , DBName VARCHAR(255)
        , VersionCreated INT
        , CurrentVersion INT
        , CreatedDate DATETIME
    ) 
    
    EXEC master.dbo.SP_MSFOREACHDB 
        @Command1 = 'USE ? INSERT INTO #DBCC EXECUTE (''DBCC DBINFO WITH TABLERESULTS'')'
        , @Command2 = 'INSERT INTO #DBCCResults (ServerName, DBName, VersionCreated, CurrentVersion, CreatedDate)
                            SELECT TOP 1 @@SERVERNAME
                            , ''?''
                            , (SELECT Value FROM #DBCC WHERE Field = ''dbi_createVersion'')
                            , (SELECT Value FROM #DBCC WHERE Field = ''dbi_version'')
                            , (SELECT Value FROM #DBCC WHERE Field = ''dbi_crdate'')
                            FROM #DBCC'
        , @Command3 = 'TRUNCATE TABLE #DBCC' 
    
    SELECT ServerName
        , DBName
        , v1.VersionName AS VersionCreated
        , v2.VersionName AS CurrentVersion
        , CreatedDate
    FROM #DBCCResults dr JOIN #version v1
        ON dr.VersionCreated = v1.VersionID
    JOIN #version v2
        ON dr.CurrentVersion = v2.VersionID
    
    DROP TABLE #version, #DBCC, #DBCCRESULTS
    
    Locations of visitors to this page

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://sankarreddy.spaces.live.com/blog/cns!1F1B61765691B5CD!463.trak
    Weblogs that reference this entry
    • None