• adam (4/15/2009)


    Thanks!

    Could someone post a screenshot of the expected output of the script would be?

    I have run the script on 2008, no errors, but there is no output. The server has several databases with a couple of users. So not sure what the issue could be.

    Hi Adam, I dont have access to a 2008 instance to test this code on. but I found the bug that was not letting the result show up. Also, Understand that this code doesn't make any changes, it just pulls existing information. The resultset was not showing up cause, the below IF statement was not TRUE for 2008(version 10.xx). The resultset will be a plain table in all the versions.

    If you look in the code, there are 2 place where I check for the Instance's product version number.

    I've updated them correctly, so that it works for 2000,2005 and 2008 as well.

    Please let me know if you have any questions.

    I changed the IF statement to the following:

    IF (LEFT(CAST(Serverproperty('ProductVersion') AS VARCHAR(1)), 1) = '9'

    OR LEFT(CAST(Serverproperty('ProductVersion') AS VARCHAR(2)), 2) = '10')

    IF EXISTS (SELECT TOP 1 *

    FROM Tempdb.sys.objects (nolock)

    WHERE name LIKE '#TUser%')

    DROP TABLE #TUser