0

I have a doubt regarding an ipynb file, it turns out that they send me a database to replicate the structure, they use SQL server Management studio, but I don't know how to import it. I thought it was a simple python script, which could create a SQL database , then Install anaconda, use %%sql statements to recreate it,

Until I realized that they could be imported in SSMS, but there is something that I am not doing well to import it correctly, I understand that it is a problem of correctly parsing the file,

import data

flat file ipynb

bad parse

I appreciate any help, thanks!

Install extensions in visual code, anaconda and the necessary libraries for handling SQL in Python, but it all boils down to correctly importing the file created in SSMS.

Dale K
  • 25,246
  • 15
  • 42
  • 71

2 Answers2

1

The ipynb is a notebook that will contain scripts to be executed against a database or create the database and objects as well.

What you are using in SSMS is a tool to import data into tables - these are not the same thing.

As mentioned by @Squirrel, SSMS does not support notebooks, BUT Azure Data Studio does support notebooks. I think that the notebook was created using Azure Data Studio (which will be installed along with SSM on your computer provided you have a recent version of SSMS.

Note that Azure Data Studio is only the name of the tool - it is not restricted to connecting to databases in Azure or running in Azure so you can use it for local or on-premises databases as well.

When you open Azure Data Studio, click on the button for Noptebooks and then the file icon to browse and open your notebook as shown

open notebook in Azure Data Studio

You will still likely have to set up your connection but that is a similar experience to SSMS.

Martin Cairney
  • 1,714
  • 1
  • 6
  • 18
  • I forgot to comment, but I also tried that, and the result was this --------------------------------------------------------------------------- NameError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_2296/2178137968.py in ----> 1 USE [master] 2 GO NameError: name 'USE' is not defined – Adrian Tagliavini Mar 30 '22 at 03:25
  • OK, so it looks like you opened the notebook OK but had an issue with running it? Can you add a screenshot of the first few cells of the notebook when you open it - it may be that it hasn't properly opened and parsed it and you may need to do some manual steps – Martin Cairney Mar 30 '22 at 03:33
0

I would suggest you to follow the below steps:

  1. Open the notebook file in Jupyter notebook and copy all the cell contents as given below: How to copy multiple input cells in Jupyter Notebook
  2. Copy the content to a single .SQL file.
  3. In the Management Studio, open a new query window and open the file, created in step no. 2 and you can run the sql statements.

SSMS New Query Window

Note: Please review the SQL file once to see if everything is falling in place. You might need to add GO statements between batches. Also, it is recommended to put semicolon at the end of statements, to make them running without issues.

Venkataraman R
  • 12,181
  • 2
  • 31
  • 58