• aleksey donskoy (10/13/2015)


    Awesome script. Works like a clock. Thanks.

    You do not need to have a stored procedure there.

    Made 3 modifications:

    1. Converted it an ad hoc query using the sysprocesses.hostname column

    2. Expanded some string variables to hold longer strings

    3. Filtered empty hostnames and duplicates as following (cut execution time by half):

    EXEC('INSERT INTO #TblHostName (Hostname) Select distinct hostname from sysprocesses where hostname <> ''''')

    The altered version below:

    Thanks for the improvements.