Está en la página 1de 10

7/8/2015

HowtomigrateaSQLServerdatabasetoalowerversion

HowtomigrateaSQLServerdatabasetoalowerversion
By:BasitFarooq|ReadComments(24)|RelatedTips:More>Restore

enteremailaddress

Join

Problem
AfterrecentlyupgradingaSQLServerinstancetoSQLServer2012afewdaysago,younoticedthatyourapplicationis
notfunctioningproperly.YoudecidedtorollbacktheupgradebydowngradingtheSQLServerdatabaseenginetoSQL
Server2008R2.Afterthedowngradeofthedatabaseengine,youareunabletoattachthedatabasesorrestorethe
backupsofthedatabases,eventhoughthedatabasecompatibilitylevelissettothedowngradedversionofSQLServer.
Youreceivethefollowingerrormessage,whenyouattempttorestorethedatabase:
Msg1813,Level16,State2,Line1
Couldnotopennewdatabase'DatabaseName'.CREATEDATABASEisaborted.
Msg948,Level20,State1,Line1
Thedatabase'DatabaseName'cannotbeopenedbecauseitisversion655.Thisserversupportsversion611
andearlier.Adowngradepathisnotsupported.

ThiserrormessageisgeneratedbecauseSQLServerautomaticallyupgradesthedatabase,whenyourestoreorattach
thedatabasefromlowerversiontohigherversion.SQLServerdoesnotallowyoutorestoreorattachadatabase
fromahigherversionofSQLServertoalowerversionofSQLServer.Inthistip,wewilllookataonetimeprocedure
whichwecanfollowtodowngradethedatabasefromahigherversion(SQLServer2012)ofSQLServertoalower
version(SQLServer2008R2)ofSQLServer.

Solution
TheerrormessageintheproblemstatementoccursbecausetheSQLServerdatabasefiles(*.mdf,*.ndfand*.ldf)and
backupsarenotbackwardcompatible.Backwardcompatibilityiswhywecannotrestoreorattachadatabasecreated
fromahigherversionofSQLServertoalowerversionSQLServer.However,thereareafewoptionsthatcanhelpus
todowngradethedatabasefromahigherversionofSQLServertoalowerversionSQLServer.Theseoptionsinclude:
GenerateScriptswizardofSQLServerManagementStudio
SQLServerIntegrationServices
CustomscriptingandBCP
InthistipwewillusetheGenerateScriptswizardofSQLServerManagementStudio.Herearethebasicstepswe
needtofollow:
ScriptthedatabaseschemainhigherversionofSQLServerbyusingtheGenerateScriptswizardofSQLServer
ManagementStudiointerface.
ConnecttothelowerversionofSQLServer,andthenruntheSQLscriptsthatweregeneratedintheprevious
step,tocreatedatabaseschemaandcopydata.
Inthenextsection,IwilldemonstratethestepsfordowngradingaSQLServer2012databasetoSQLServer2008R2
database.
Note:Fordemonstrationpurpose,I'llbedowngradingtheOUTLANDERdatabasehostedonmySQLServer2012
instance(IITCUK\DEV01)toSQLServer2008R2instance(IITCUK\SQLSERVER2008).

StepbyStepDemo:DowngradingaSQLServer2012databasetoSQLServer2008R2
Step1:ScripttheschemaoftheOUTLANDERdatabaseontheSQLServer2012instance(IITCUK\DEV01)usingthe
GenerateScriptswizardoftheSQLServerManagementStudiointerface.
InObjectExplorerconnecttoIITCUK\DEV01,rightclickOUTLANDERdatabase,expandTasksandchoose
"GenerateScripts...".

LatestfromMSSQLTips
SecuringSQLServerwithSQLSecure

https://www.mssqltips.com/sqlservertip/2810/howtomigrateasqlserverdatabasetoalowerversion/

1/10

7/8/2015

HowtomigrateaSQLServerdatabasetoalowerversion

SQLServerandPostgreSQLForeign
DataWrapperConfigurationPart3
BuildingyourBrandasaSQLServer
ProfessionalwithHighQuality
Feedback
SQLServerDatabaseMirroring
AutomaticPageRepair
SQLServerReportingServicesText
BoxOrientation
NewTrainingClassWindowsServer
FailoverClusteringfortheSQLServer
DBA
NewWebcastEncryptingDatawith
SQLServerJuly9th
3TipsforManagingLargeNumbersof
SQLServerJobs
AccelerateSQLServerwithFlash
Storage
OnDemandWebcastPerformSQL
ServerBackupsAcrossYourServers
OnDemandWebcastPerformance
insightsandtuningofPhysicaland
VirtualSQLServers
OnDemandWebcastImplementinga
SANLessSQLServerClusterinUnder
anHourWebcast

ThislaunchesGenerateandPublishScriptswizard.ClickNext,toskiptheIntroductionscreenandproceedtothe
ChooseObjectspage.

OntheChooseObjectspage,chooseoption"Scriptentiredatabaseandalldatabaseobjects",andthenclick
Nexttoproceedto"SetScriptingOptions"page.

FreeSQLServerLearning
GetyourSQLServer
inshapethisSummer
withSpotlightonSQL
Server

https://www.mssqltips.com/sqlservertip/2810/howtomigrateasqlserverdatabasetoalowerversion/

2/10

7/8/2015

HowtomigrateaSQLServerdatabasetoalowerversion
EncryptingDatawith
SQLServer

PhysicalandVirtual
Performance
MonitoringwithSQL
DiagnosticManager

OntheSetScriptingOptionspage,specifythelocationwhereyouwanttosavethescriptfile,andthenchoosethe
Advancedbutton.

InAdvancedScriptingOptionsdialogbox,setScriptTriggers,IndexesandPrimaryKeyoptionstoTrue,Script
forServerVersiontoSQLServer2008R2,andTypesofdatatoscripttoSchemaandData.Thislastoptionis
keybecausethisiswhatgeneratesthedatapertable.

https://www.mssqltips.com/sqlservertip/2810/howtomigrateasqlserverdatabasetoalowerversion/

3/10

7/8/2015

HowtomigrateaSQLServerdatabasetoalowerversion

Oncedone,clickOK,tocloseAdvancedScriptingOptionsdialogboxandreturntoSetScriptingOptionspage.In
SetScriptingOptionspage,clickNexttocontinuetoSummarypage.
AfterreviewingyourselectionsonSummarypage,clickNexttogeneratescripts.

Oncescriptsaregeneratedsuccessfully,choosetheFinishbuttontoclosetheGenerateandPublishScriptswizard.

https://www.mssqltips.com/sqlservertip/2810/howtomigrateasqlserverdatabasetoalowerversion/

4/10

7/8/2015

HowtomigrateaSQLServerdatabasetoalowerversion

Step2:ConnecttotheSQLServer2008R2instance(IITCUK\SQLSERVER2008),andthenruntheSQLscriptsthatwere
generatedinStep1,tocreatetheOUTLANDERdatabaseschemaandcopyitsdata.
InObjectExplorerconnecttoIITCUK\SQLServer2008,theninSQLServerManagementStudio,opentheSQL
ServerscriptyousavedinStep1.

https://www.mssqltips.com/sqlservertip/2810/howtomigrateasqlserverdatabasetoalowerversion/

5/10

7/8/2015

HowtomigrateaSQLServerdatabasetoalowerversion

Modifythescript,tospecifythecorrectlocationfortheOUTLANDERdatabasedataandlogfiles.Oncedone,runthe
scripttocreatetheOUTLANDERdatabaseonIITCUK\SQLServer2008instance.

Uponsuccessfulexecution,refreshtheDatabasefolderinObjectExplorer.Asyoucanseeinthefollowingimage
OUTLANDERdatabasehasbeensuccessfullydowngraded.

NextSteps
Toavoidthisissue,alwaysmakesurethatyouperformafullbackupofthedatabasebeforeyouupgradetheSQL
ServeranddatabasetoahigherversionofSQLServer.Inaddition,besuretothoroughlytesttheapplication
priortoreleasingtheapplicationtotheusers.
Considerthisdowngradeoptionasyourlastoptiontorollbackfromanupgradebecausethetimeandstorage
neededcanbeverylarge.
Withaverylargedatabasebesureyouhavesufficientstoragetosupportthedataneeds.
Besuretoverifyrowandobjectcountsaswellastestyourapplicationbeforereleasingtoproduction.
AdditionalResources:
WhyCan'tIRestoreaDatabasetoanOlderVersionofSQLServer?
SQLServerDatabaseEngineBackwardCompatibility
SQLServerUpgradeTips

LastUpdate:11/15/2012

Abouttheauthor
https://www.mssqltips.com/sqlservertip/2810/howtomigrateasqlserverdatabasetoalowerversion/

6/10

7/8/2015

HowtomigrateaSQLServerdatabasetoalowerversion
BasitFarooqisaSeniorDatabase
Administratorandhasworkedinthe
ITindustryfor11+years.

RelatedResources
MoreSQLServerDBATips...

Viewallmytips

Print

Share

Like

Tweet

Becomeapaidauthor

EnterEmailAddress

Join

LearnMore

Postacommentorlettheauthorknowthistiphelpedyou.
Allcommentsarereviewed,sostayonsubjectorwemaydeleteyourcomment.
*Name

Notifyforupdates

*Email
Paragraph

***NOTE***IfyouwanttoincludecodefromSQLServerManagementStudio(SSMS)inyourpost,pleasecopythecodefromSSMSandpaste
thecodeintoatexteditorlikeNotePadbeforecopyingthecodebelowtoremovetheSSMSformatting.

Note:youremailaddressisnotpublished.Requiredfieldsaremarkedwithanasterisk(*)
GetfreeSQLtips:
*EnterCode

Monday,June08,20155:19:21AMmeysam

SaveComment

ReadTheTip

Thank,s
biglike

Tuesday,May19,20154:44:21AMKenneth

ReadTheTip

Hi,Ireceivedanerrorsaying"Directorylookupforthefile"C:\Database\SampleDB.mdf"failedwiththeoperating
systemerror3(Thesystemcannotfindthepathspecified).
EvenIcreatedafolderwiththesamelocationasmentionabove.Whatdoyouthinkistheproblemtothis?BTWI'm
justexecutingSchemaScriptnotSchemaandData.

Thursday,May07,201510:16:06PMAshwinPai

ReadTheTip

ThanksBoss,lifesaver!

Thursday,May07,20154:55:18AMRaja

ReadTheTip

nice,itssavemytime..thanks

https://www.mssqltips.com/sqlservertip/2810/howtomigrateasqlserverdatabasetoalowerversion/

7/10

7/8/2015

HowtomigrateaSQLServerdatabasetoalowerversion

Thursday,April09,20151:19:30AMKrushna

ReadTheTip

Thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Monday,March02,20159:07:58AMnakaoh

ReadTheTip

itnotworkforBigdabase(mydatabase5GB)

Saturday,November22,20143:45:36PMMohamed

ReadTheTip

Butitdidn'tworkwhenichoosesqlserver2005

Tuesday,October07,20144:59:24AMPratiK

ReadTheTip

Makesnapshotreplicationforrequireddatabaseininferiorversionfromsuperiorversion,Thisisveryfast.
Itworksforme.

Tuesday,August05,201412:21:57PMIWouldLikeToUseThisArticle

ReadTheTip

Hello,
Inyourdocument,youwrote"scriptprimarykeyoptiontotrue"butinyourpicture,youbordered"foreignkey".
Please,canyoutellme/uswhatisthegoodoption?
Bestregards.

Tuesday,June10,20148:53:56PMJohnHamilton

ReadTheTip

Toavoidtheheadachesoftextfileandscriptsizeonlargedatasets,youcansimplywriteaqueryagainstanother
serverandsavetheresultsetintoyourcurrentserver.

SELECT*INTO2008TableFROM2012Server.2012Database.2012Table

Youwillneedtosetupa"linkedserver"first.Thiswilleliminatethesloppylargescriptsandlettheserverstalk
directlytoeachother.

Wednesday,December04,20136:58:57PMRaymondNey

ReadTheTip

Greatarticle.Thankyou.ItworkedformeasIwasn'tquitereadytomovetoSQL2012yetandhadasmallDBI'd
liketouseon2008.Iusedatexteditor(editpluswasmychoice),thencopy/pastedintoSSMSasmuchasSSMS
couldhandleandthatseemedtodothejob.Myscriptwas880megs.AbittoomuchtoloadintoSMSS.
Thanksagainforthearticle.Beenafanofthissiteformanyyears!

Wednesday,April17,20133:35:27PMVarun

ReadTheTip

AspointedoutbyMarkPointon
Thisseemstobemisleading,ifthereareNEWTSQLfunctionsusedwithinyourStoredProcedureslike(LAG,LEADor
evenOVERCLAUSEwithRANGEattribute)generatingaSQL2008compatiblescriptsdoesn'tautomaticallyconverts
thosetoSQL2008standardandwouldresultinerroruponcalling.

Monday,January14,201312:30:56AMPaulAndrew

ReadTheTip

Sorry,ignoremyquestion.Iunderstandnowthatthesefilesaretoolargetobeopened.

Sunday,January13,201312:35:34PMPaulAndrew

ReadTheTip

ThescripthasbeencreatedontheSQL2012serverandcopiedovertomySQL2008R2serverbutwhenItrytoopen
the.sqlfilethiserrorpopsup:ErrorHRESULTE_FAILhasbeenreturnedfromacalltoaCOMcomponent.

https://www.mssqltips.com/sqlservertip/2810/howtomigrateasqlserverdatabasetoalowerversion/

8/10

7/8/2015

HowtomigrateaSQLServerdatabasetoalowerversion
Haveyouseenthisbefore?AnyideawhatIshouldtrytogetbeyondtheerror?IamtryingtorestoretwoSQL2012databasesfrom.bakfiles,originalsizes
27GBand7GBandtheycreatedscriptsof577GBand184GB.

Thanks,Paul

Sunday,November25,20124:09:20PMLucDM

ReadTheTip

@RDFrancispoint4:anothercontstraintthatneedstobestrippedoutofthescript(andreenabledafterwards)is
IDENTITY.NotpossibletoimportdataintoanactiveIDENTITYcolumn.

Wednesday,November21,20128:13:49AMJeremyKadlec

ReadTheTip

JYandsreekanth,
Thankyouforthefeedbackandsorryforanyconfusion.Wehaveupdatedthetiptitle.Letusknowifthismakes
moresense.
Thankyou,
JeremyKadlec

Tuesday,November20,201211:05:38AMJohnJakob

ReadTheTip

Anotherconsiderationhereisreferentialintegrity.Evenforsmalldatabases,ifyourdatabasehasgoodRI(lotsof
foreignkeys),youmaygetintotroublewhenyoutrytorunthescripts,becauseofdatadependencies!
Youmayfindthatyouhavetopopulateyourtablesinacertainorder,sothatparenttablesarepopulatedbeforechild
tables,etc.Sometimesthissequenceofdatapopulationcanbeaccommodatedbyrunningthescriptsinacertain
orderbutthatcouldbecometedious...
Abetterapproach(thatI'veusedinthepast)istoeditthescriptfilesmanually,andSTRIPOUTalltheFK
constraints,savingthemofftoaseparatefile.Thenrunthescriptsasnormalonthetarget,gettingdataintoallthe
tablesfirst.Then,afterallthetableshavedatainthem,startapplyingtheFKscripts.

Tuesday,November20,201210:43:12AMJohnJakob

ReadTheTip

Yes,thescriptingofschemaanddatawillcertainlywork.
Butitisnotaverypracticalsolutionforlargerdatabasesi.e.,withtablescontainingmillionsofrows.
ThescriptswillbeHUGE,anditwilltakeprohibitivelyLONGtorunthosescripts!
DBAsshouldunderstandthat.
j

Tuesday,November20,20129:49:53AMJJ

ReadTheTip

Thanksfortheinfo.Veryhelpful.

Monday,November19,20125:00:42PMsreekanthbandarla

ReadTheTip

Ifeel,changingthetitleto"MigratingDatabase/MovingDataManuallytoalowerVersion".IMHO,Restoringthe
DatabasetoLowerVersionisIncorrectandMisleadingTitle.

Friday,November16,20129:00:05AMBasit

ReadTheTip

Mark,
ihavetestedthisprocedurebydowngradingSQLServer2012databasetoSQLServer2008R2.Thisworksperfectly
fineforme.Seeabovescreenshots.TheoptionsareslightlydifferentinSQLServer2008,2005and2000.

Friday,November16,20123:54:38AMMarkPointon

ReadTheTip

I'dliketohiglightthefollowingsectionfromyourarticle:
InAdvancedScriptingOptionsdialogbox,setScriptTriggers,IndexesandPrimaryKeyoptionstoTrue,
ScriptforServerVersiontoSQLServer2008R2,andTypesofdatatoscripttoSchemaandData.Thislast
optioniskeybecausethisiswhatgeneratesthedatapertable.
Pleasecanyouconfirmthatyouhavetestedthefeatureofscriptingforaparticularenvironment,inthesqlversion
youareusing.IraisethisasthisfeaturedoesnotworkinSQL2008.I'dscripteda2008dbtorestoreontoa2005db
anditstillincludeSQL2008specificcommandsanddatatypes.
I'dguessingthisfeaturestilldoesnotwork.

https://www.mssqltips.com/sqlservertip/2810/howtomigrateasqlserverdatabasetoalowerversion/

9/10

7/8/2015

HowtomigrateaSQLServerdatabasetoalowerversion
Thursday,November15,20122:01:24PMJY

ReadTheTip

Thisisamisleadingtitleasthereisnowayto"restoeasqlserverdatabasetoalowerversion".Whatisdescribed
hereinthetipishowtomigrateasqldbtoalowerversion.

Thursday,November15,201210:31:54AMRDFrancis

ReadTheTip

Dokeepinmind,ofcourse,thatthisisprobablynotapracticaloptionwithalargedatabase.WhenI'vehadtodo
thiswith510GBDBs,especiallywhenIknowI'llbedoingitmorethanonce(datacominginfromanexternalsite
thatrunninganewerversionofSQLthanweare),IuseavariationofthisplusSSIS,asfollows:
1.GeneratetheDBscriptsasabove,schemaonly.
2.Createtheemptydatabase.
3.Usethe"Import/Export"commandstoimportdatafromthenewerversionDBintotheolderone.SavetheSSIS
packagethusgenerated.
4.Youmayneedtomodifythedefaultcolumnmappingsforinstance,iftherearecolumnsofthetimestamp
datatype,thosecan'tactuallybemovedoverthisway.

SponsorInformation

24/7SQLServerMonitoringTools|SQLDiagnosticManager|TryforFree
Trackeverydatabasechange:seewhomakeschanges,whytheydidit&anyaffectedobjects.Seehow
SolvingSQLServerproblemsformillionsofDBAsandDevssince2006.Joinnow.
DownloadthecompleteperformancesolutionforSQLServerandWindows
FreeLearningClickheretobecomeabetterSQLServerProfessional

Follow

Learning

Resources

Search

Community

MoreInfo

GetFreeSQLTips

DBAs

Tutorials

TipCategories

FirstTimer?

Join

Twitter

Developers

Webcasts

SearchByTipID

Pictures

About

LinkedIn

BIProfessionals

Whitepapers

Authors

FreeTshirt

Copyright

Google+

Careers

Tools

Contribute

Privacy

Facebook

QandA

Events

Disclaimer

Pinterest

Today'sTip

UserGroups

Feedback

AuthoroftheYear

Advertise

RSS

Copyright(c)20062015EdgewoodSolutions,LLCAllrightsreserved

Somenamesandproductslistedaretheregisteredtrademarksoftheirrespectiveowners.

https://www.mssqltips.com/sqlservertip/2810/howtomigrateasqlserverdatabasetoalowerversion/

10/10

También podría gustarte