-1

I need to fetch the 'CREATE TABLE' code with all primary keys,indexes, collation etc. from on prem SQL Server db to Databricks and then from Databricks to Azure SQL db.

I have already connection to both SQL Server databases from Databricks. I'm using JDBC driver.

1
  • 1
    If you only need it once, you can script tables by SSMS tool, right click on table in the Object Explorer and choose Script table Commented Jun 19, 2023 at 21:07

1 Answer 1

1

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.

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

Comments

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.