[SQL SERVER][Maintain]如何降級資料庫
如果你有強烈理由需要降級資料庫的話,
這裡推薦使用SSMS匯出指令碼功能來處理會比較順利,
當然,升級資料庫一定是比較好的選擇,
因為你可以享受相關新特性所帶來的便利、高效能...等優點。
1.產生指令碼 For SQL2005
選取來源資料庫
版本選擇SQL2005
儲存檔案
2.SQL2005先建立空資料庫
執行前面所匯出Scripts
前面Scripts執行成功後,接下來再匯出 Data(其他選項我都設定 false )
整理相關檔案(依 Schema 分類)
dir /B * | find "dbo" >d:\dbo.txt
for /f %i in (d:\dbo.txt) do move %i D:\myscripts\dbo
dir /B * | find "HumanResources" >d:\HumanResources.txt
for /f %i in (d:\HumanResources.txt) do move %i D:\myscripts\HumanResources
dir /B * | find "Person" >d:\Person.txt
for /f %i in (d:\Person.txt) do move %i D:\myscripts\Person
dir /B * | find "Production" >d:\Production.txt
for /f %i in (d:\Production.txt) do move %i D:\myscripts\Production
dir /B * | find "Purchasing" >d:\Purchasing.txt
for /f %i in (d:\Purchasing.txt) do move %i D:\myscripts\Purchasing
dir /B * | find "Sales" >d:\Sales.txt
for /f %i in (d:\Sales.txt) do move %i D:\myscripts\Sales
建立執行Script List
for /f %i in (d:\dbo.txt) do echo :r D:\myscripts\dbo\%i >>D:\myscripts\list.sql
for /f %i in (d:\HumanResources.txt) do echo :r D:\myscripts\HumanResources\%i >>D:\myscripts\list.sql
for /f %i in (d:\Person.txt) do echo :r D:\myscripts\Person\%i >>D:\myscripts\list.sql
for /f %i in (d:\Production.txt) do echo :r D:\myscripts\Production\%i >>D:\myscripts\list.sql
for /f %i in (d:\Purchasing.txt) do echo :r D:\myscripts\Purchasing\%i >>D:\myscripts\list.sql
for /f %i in (d:\Sales.txt) do echo :r D:\myscripts\Sales\%i >>D:\myscripts\list.sql
開啟 SSMS 並貼上Script List(請開啟SQL CMD MODE)
成功後就大功告成了。