• Is that more than 16 data files? Or is it with log files?

    sp_attach_db has hardcoded 16 file limit because of the parameters. Look at the code. If you're doing more than that, someone must have modified your procedure.