microsoft / sqlmanagementobjects

Sql Management Objects, an API for scripting and managing SQL Server and Azure SQL Database
Other
127 stars 20 forks source link

Using SMO to extract the External Sources Information from Synapse SQL Serverless #69

Open immsgbb opened 3 years ago

immsgbb commented 3 years ago

I am trying to script the Synapse SQL Serverless objects and mainly External Sources objects. Which mainly consist of External File Format and External Data Sources.

Is it possible ?

$scrp.Script($dbs["stg"].ExternalDataSources) Multiple ambiguous overloads found for "Script" and the argument count: "1". At line:1 char:1

script function doesn't work with external data source. Is there another way to script it ?

shueybubbles commented 3 years ago

What type is $scrp Is it a Scripter? You should probably use EnumScript instead of Script , as it returns an IEnumerable<string> instead of a StringCollection. Also, both methods take arrays as input so you probably need to use Linq or some other way to convert the collection to an array so the reflection code in powershell can pick the right method.

immsgbb commented 3 years ago

$scrp = new-object ('Microsoft.SqlServer.Management.Smo.Scripter') ($s)