-1

I'm switching versions of SQL Server (2014 to 2019) in a company that has over 3.000 databases. Migration system keeps crashing on me so I feel like the best way is to just copy the files and attach to the new server, the problem is SSMS can only attach 1 by 1 and it's over 3k companies.

Any way or script to do it by bulk? Attach every .MDF database file in a folder to my server?

jarlh
  • 42,561
  • 8
  • 45
  • 63
  • Does this answer your question? [Attach multiple databases using T-SQL](https://stackoverflow.com/questions/10835153/attach-multiple-databases-using-t-sql) – Martheen Aug 14 '22 at 13:49
  • Use Powershell and DBAtools. [Mount-DbaDatabase](https://docs.dbatools.io/Mount-DbaDatabase) is your friend – Charlieface Aug 14 '22 at 14:49

1 Answers1

-2

Create a directory in your server say c:\Test . Inside test place your all MDF files of those 3000 DB's Now in your SSMS use this command :

USE master
GO
EXEC dbo.usp_MultiAttachSingleMDFFiles 'C:\Test' 
GO 
  • "usp_MultiAttachSingleMDFFiles" is a custom procedure, not a built-in function. – s3b Mar 31 '23 at 09:22