任务>生成脚本>脚本整个数据库和所有数据库对象>高级>数据类型到脚本:仅数据
这给我一个关于循环依赖的错误.如果我将数据类型更改为脚本到模式和数据,它会生成罚款.如何解决这个问题呢?
Action Result Getting a list
of objects from MyDatabase FailedDetailed report:
Microsoft.sqlServer.Management.sqlScriptPublish.sqlScriptPublishException:
An error occurred while scripting the objects. —>
Microsoft.sqlServer.Management.Smo.SmoException: Cyclic dependencies
found. at
Microsoft.sqlServer.Management.Smo.SmoDependencyOrderer.DependencyGraphTraversal(Int32
num,Dictionary2 dictionary,List
1 sortedList,HashSet1 visited,
1 current) at
HashSet
Microsoft.sqlServer.Management.Smo.SmoDependencyOrderer.DependencyGraphTraversal(Int32
num,
HashSet1 current) at
Microsoft.sqlServer.Management.Smo.SmoDependencyOrderer.SortDictionary(Dictionary2
1
dictionary) at
Microsoft.sqlServer.Management.Smo.SmoDependencyOrderer.SortDataSet(DataSet
ds) at
Microsoft.sqlServer.Management.Smo.SmoDependencyOrderer.SortDataSet(List
objectList,Dictionary2 idDictionary,DataSet ds) at
1
Microsoft.sqlServer.Management.Smo.SmoDependencyOrderer.ExecuteQueryUsingTempTable(List
objectList,List1 list,String query) at
1
Microsoft.sqlServer.Management.Smo.SmoDependencyOrderer.ResolveTableOnlyDependencies()
at
Microsoft.sqlServer.Management.Smo.SmoDependencyOrderer.ResolveDependencies()
at
Microsoft.sqlServer.Management.Smo.SmoDependencyOrderer.Order(IEnumerable
urns) at
Microsoft.sqlServer.Management.Smo.ScriptMaker.DiscoverOrderScript(IEnumerable1
1
urns) at
Microsoft.sqlServer.Management.Smo.ScriptMaker.ScriptWorker(List
urns,ISmoScriptWriter writer) at
Microsoft.sqlServer.Management.Smo.ScriptMaker.Script(Urn[] urns,
ISmoScriptWriter writer) at
Microsoft.sqlServer.Management.sqlScriptPublish.sqlScriptGenerator.DoScript(ScriptOutputOptions
outputOptions) — End of inner exception stack trace — at
Microsoft.sqlServer.Management.sqlScriptPublish.GeneratePublishPage.worker_DoWork(Object
sender,DoWorkEventArgs e) at
System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e) at
System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object
argument)
Then,on a whim,knowing that I had successfully scripted this database before,I connected to the sql Server 2012 instance using sql Server Management 2008 R2,and I was able to generated the scripts without error!!
Note,that I did data-only,and I had to allow it to script all database objects. I tried to select only certain tables,but that gave some other errors that I wasn’t willing to track down,so I just did the whole thing.