title: Generate Scripts - Data only - Cyclic dependencies found error
body: <p>I'm trying to generate a script of all the data in a database so I can move just the data over to an identical database on another server. In SQL Server 2012 I right click on the source database </p>
  
  <p><strong>Tasks > Generate Scripts > Script entire database and all database objects > Advanced > Types of data to script: data only</strong> </p>
  
  <p>This gives me an error something about a Cyclic dependency. If I change the type of data to script to <strong>schema AND data</strong> it generates fine. How can I fix this to work with data only?</p>
  
  <blockquote>
    <p>Action                                         Result Getting a list
    of objects from MyDatabase      Failed</p>
    
    <p>Detailed report: </p>
    
    <p>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, Dictionary<code>2 dictionary, List</code>1 sortedList, HashSet<code>1 visited,
    HashSet</code>1 current) at
    Microsoft.SqlServer.Management.Smo.SmoDependencyOrderer.DependencyGraphTraversal(Int32
    num, Dictionary<code>2 dictionary, List</code>1 sortedList, HashSet<code>1 visited,
    HashSet</code>1 current) at
    Microsoft.SqlServer.Management.Smo.SmoDependencyOrderer.DependencyGraphTraversal(Int32
    num, Dictionary<code>2 dictionary, List</code>1 sortedList, HashSet<code>1 visited,
    HashSet</code>1 current) at
    Microsoft.SqlServer.Management.Smo.SmoDependencyOrderer.DependencyGraphTraversal(Int32
    num, Dictionary<code>2 dictionary, List</code>1 sortedList, HashSet<code>1 visited,
    HashSet</code>1 current) at
    Microsoft.SqlServer.Management.Smo.SmoDependencyOrderer.SortDictionary(Dictionary<code>2
    dictionary) at
    Microsoft.SqlServer.Management.Smo.SmoDependencyOrderer.SortDataSet(DataSet
    ds) at
    Microsoft.SqlServer.Management.Smo.SmoDependencyOrderer.SortDataSet(List</code>1
    objectList, Dictionary<code>2 idDictionary, DataSet ds) at
    Microsoft.SqlServer.Management.Smo.SmoDependencyOrderer.ExecuteQueryUsingTempTable(List</code>1
    objectList, List<code>1 list, String query) at
    Microsoft.SqlServer.Management.Smo.SmoDependencyOrderer.ResolveTableOnlyDependencies()
    at
    Microsoft.SqlServer.Management.Smo.SmoDependencyOrderer.ResolveDependencies()
    at
    Microsoft.SqlServer.Management.Smo.SmoDependencyOrderer.Order(IEnumerable</code>1
    urns) at
    Microsoft.SqlServer.Management.Smo.ScriptMaker.DiscoverOrderScript(IEnumerable<code>1
    urns) at
    Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptWorker(List</code>1
    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)</p>
  </blockquote>