• You just made me wish all over again that MS had gone with Python. The code is so much more readable:

    import pyodbc

    def Test_SQLConnection(Instances):

    ret = []

    for Instance in Instances:

    try:

    conn = pyodbc.connect('DRIVER={SQL Native Client};SERVER=' + Instance + ';Trusted_Connection=yes;')

    curs = conn.cursor()

    curs.execute("SELECT @@SERVERNAME as Name,Create_Date FROM sys.databases WHERE name = 'TempDB'")

    for row in curs:

    ret.append((row.Name, row.Create_Date))

    except:

    pass

    return ret

    No braces (except for the connection string, of course); no $-signs

    Gerald Britton, Pluralsight courses