'Find the indexes that apply to a column, needed when deleting'

def _find_indexes_for_column(self, table_name, name):

    sql = "\n                                SELECT    si.name,    si.id,    sik.colid,    sc.name\n                                FROM    dbo.sysindexes    si    WITH    (NOLOCK)\n                                INNER    JOIN    dbo.sysindexkeys    sik    WITH    (NOLOCK)\n                                                ON        sik.id    =    si.id\n                                                AND    sik.indid    =    si.indid\n                                INNER    JOIN    dbo.syscolumns    sc    WITH    (NOLOCK)\n                                                ON        si.id    =    sc.id\n                                                AND    sik.colid    =    sc.colid\n                                WHERE    si.indid    !=0\n                                                AND    si.id    =    OBJECT_ID('%s')\n                                                AND    sc.name    =    '%s'\n                                "
    idx = self.execute((sql % (table_name, name)), [])
    return [i[0] for i in idx]
