4

I tried to generate Scripts from our companies Azure SQL-Database. As I did two weeks before I connected to the DB with my Management Studio Client and ran the "Generate Scripts"-Wizard in the Context of the concerned DB. The wizard failed at "Getting the list of objects from 'db'." and pointed out the following Stack Trace:

Microsoft.SqlServer.Management.SqlScriptPublish.SqlScriptPublishException: An error occurred while scripting the objects. ---> System.InvalidCastException: Die angegebene Umwandlung ist ungültig. at Microsoft.SqlServer.Management.Smo.Table.Microsoft.SqlServer.Management.Smo.IPropertyDataDispatch.SetPropertyValue(Int32 index, Object value) at Microsoft.SqlServer.Management.Smo.PropertyDispatcher.SetValue(Int32 index, Object value) at Microsoft.SqlServer.Management.Smo.PropertyCollection.SetValue(Int32 index, Object value) at Microsoft.SqlServer.Management.Smo.SqlSmoObject.AddObjectPropsFromDataReader(IDataReader reader, Boolean skipIfDirty, Int32 startColIdx, Int32 endColIdx) at Microsoft.SqlServer.Management.Smo.SqlSmoObject.ImplInitialize(String[] fields, OrderBy[] orderby) at Microsoft.SqlServer.Management.Smo.SqlSmoObject.OnPropertyMissing(String propname, Boolean useDefaultValue) at Microsoft.SqlServer.Management.Smo.PropertyCollection.RetrieveProperty(Int32 index, Boolean useDefaultOnMissingValue) at Microsoft.SqlServer.Management.Smo.PropertyCollection.GetPropertyObject(Int32 index) at Microsoft.SqlServer.Management.Smo.SqlSmoObject.GetPropertyOptional(String propName) at Microsoft.SqlServer.Management.Smo.Column.EmbedDefaultConstraints() at Microsoft.SqlServer.Management.Smo.Column.GetPropagateInfo(PropagateAction action) at Microsoft.SqlServer.Management.Smo.SqlSmoObject.GetPropagateInfoForDiscovery(PropagateAction action) at Microsoft.SqlServer.Management.Smo.SmoDependencyDiscoverer.GetScriptableChildren(List1 propInfoList, PropagateAction propagateAction) at Microsoft.SqlServer.Management.Smo.SmoDependencyDiscoverer.SfcChildrenDiscovery(HashSet1 discoveredUrns) at Microsoft.SqlServer.Management.Smo.SmoDependencyDiscoverer.Discover(IEnumerable1 urns) at Microsoft.SqlServer.Management.Smo.ScriptMaker.Discover(IEnumerable1 urns) at Microsoft.SqlServer.Management.Smo.ScriptMaker.DiscoverOrderScript(IEnumerable1 urns) at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptWorker(List1 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)

The @@VERSION-Query returns the following record:

Microsoft SQL Azure (RTM) - 11.0.9231.13 Jul 15 2015 11:58:32 Copyright (c) Microsoft Corporation

And here is some additional information copied from the SSMS-Help:

Microsoft SQL Server Management Studio 12.0.4100.1 Microsoft Analysis Services Client Tools 12.0.4100.1 Microsoft Data Access Components (MDAC) 6.1.7601.17514 Microsoft MSXML 3.0 6.0 Microsoft Internet Explorer 9.11.9600.17843 Microsoft .NET Framework 4.0.30319.42000 Operating System 6.1.7601

Can you tell me what's going wrong here?

Thanks in Advance.

Alan

2
  • I do not get any diagnostic information at all when the generation of the script fails. How did you obtain diagnostics? Commented Sep 7, 2016 at 8:59
  • Honestly... Since its more than a year ago from now, I don't remember anymore. But it wasn't hard to find. Maybe in the output/report? :) Commented Sep 8, 2016 at 13:57

3 Answers 3

4

I had the same problem . To resolve I switched to another directory that sql server could write .

Worked for me.

I hope you solve your problem , since the error message is not clear.

Sign up to request clarification or add additional context in comments.

1 Comment

Many thanks for your reply! I finally "solved" the problem by simply buying a new PC (since it was anyway high time for me to do so, lol ;-). However, I still didn't find out what the source of this strange error actually was. Since I'm working on my new PC I never had this issue anymore. I will keep your approach in mind for the case that I will run into this kind of trouble again.
2

Check server free space. I resolved same problem by make free space on server.

Comments

1

Make sure you can write to the file in that folder. In my case, I was saving the script in the C:\ drive, for example, c:\script.sql, and after I changed to another folder it worked.

1 Comment

Similar problem. Tried to change the folder - no go - tried to restart - still no go. Selected was data_only option. Switching to data and schema allowed the server to write the files. (SQL Server 2014 (SP3) (KB4022619) 12.0.6024.0 (x64) Sp 7 2018)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.