sql server – Pull code from on prem database to create AZURE SQL table including indexes, constraints, keys, etc. using pyspark

There’s no built-in TSQL api to generate full-fidelity DDL for existing objects. The Sql Server Management Objects (SMO) .NET library is the official component that does DDL generation.

So not the most natural thing to use from Databricks, but technically possible.

Users have created more or less elaborate TSQL solutions for this for decades.
See: How to generate create script of table using SQL query in SQL Server for some links.

If you don’t need full fidelity, you can just use Spark JDBC to open a DataFrame from one SQL Server and write it to the other.

Read more here: Source link