cancel
Showing results for 
Search instead for 
Did you mean: 

How do I open a SqlScript file in Hana Studio and have it connected to a schema?

Former Member
0 Kudos

Using Hana Studio how do I open a .sql file and have it connected to a specific databse/schema?

Normally I create a new SQL Console window and start running queries. When I'm done I save that script to a file. The next time I come into Hana Studio I want to be able to open that file and automatically (or manually) connect it to the same schema I was using before.

I can't run "set schema..." because the SQL Console window is not connected to a system. And the connection info at the top of the window (Connection Profile) doesn't list my Hana system, just other stuff like DB2, Postgres, etc.

There must be a way to "attach" the current SQL Console window to a system/database/schema.

Thanks,

Tim

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member

Hi Tim,

by default, SQL files are associated with the default SQL File Editor (which does not support HANA connections). However, you can change the default SQL editor to the HANA SQL Console by...

- going to Window -> Preferences

- type "File Associations" in the filter and click on the menu item

- in the upper section "File types", search for *.sql

- in the lower section, select "SAP HANA SQL console", and on the right-hand side click on "Default"

Now, when you open any .sql file, it will open in the HANA SQL editor, and you may "Choose connection", as described by Dimitri already.

Alternatively, you can save your files as *.sdbsql, which is associated with HANA SQL Editor by default.

former_member255270
Active Participant
0 Kudos

Hi Tim, unfortunately there is not command that will let you connect to a database directly via SQL Editor. The only option is to use the "Choose connection" button in the upper right corner of the console. It will list only those instances that you have already stored a set of user credentials for in secure storage. So if you do not see your instance listed then it means you have not saved your credentials.

To save the login usernames and password in the secure area, double click your gray icon representing your SID in the systems pane (on the left). You will be prompted to enter a username and password, be sure to check "Store user name and password in secure storage".

That SID should not be visible in the "Choose connection" button in the upper right corner of the SQL editor.

Former Member
0 Kudos

Thanks Dimitri, I hadn't seen that before. Unfortunately the "Choose Connection" button is only available on query windows that are already connected to a system.

I need to be able to start Hana Studio, then open a file, then attach it to a system. I guess I could open a new query window for a specific system, then copy the contents of the script file into it, but that seems less intuitive, and harder to save any changes I make to my queries.