Assuming the files are named DB.mdf and the log files are DB_log.ldf:exec master..xp_cmdshell 'for %a in (C:\Path\*.mdf) do @echo exec sp_attach_db ''%~na'', ''%a'', ''%~dpn_log.ldf'' '
That will generate the necessary SQL to attach all the files in C:\Path. Change as necessary, copy and paste the results in a new window.I blogged about the DOS for command a while back if you're interested: http://weblogs.sqlteam.com/robv/category/128.aspx