Execute SQL file in Snowflake through Snowsight Editor - snowflake-cloud-data-platform

I am using the Snowsight Query Editor. Is there any option to run multiple queries or a execute sql file?
Tried to use snowsql command which couldnot help

In Snowsight UI worksheets, You can run multiple queries by selecting the queries and clicking the run button.Run button image
To execute all the queries in the worksheet, click on the 'drop-down arrow' and select 'Run All'.
To execute a script SQL file in snowsight UI, click on the menu image next to your worksheet name and then click on the option 'Import SQL from file'.
screenshot showing the 'import SQL from file' option

Related

Snowflake - How to view all stage files using show stage

I used the below query in my worksheet. It ran successfully.
use database kaditdb;
use schema public;
show stages;
But when I click into Data preview button of Stages under Database section (left pane of classic console ) => Snowflake - Account usage ->Stages
Why are these files not known by show stages command?
Thanks.

How do you re-run an already executed query from 'Query History' pgadmin?

As in pgAdmin 4 screenshot, one can see a list of recently executed queries.
The play button, Execute / Refresh(F5) tool executes the most recent query instead of the selected/highlighted one.
I know I can click on a query, and from the right side pane click on copy and go to the Query Editor to run it.
My question is, is there a shortcut or some options using GUI in pgAdmin 4 to re-run the query of my choice (selected/highlighted query) from history?
Unfortunately, you cannot execute this in View/Edit table mode. However, you can copy the SQL and open a new query tool, paste the query and run it.

Export multiple stored procedures to text files

In SQL Server Management Studio, I have a database with 200 stored procedures. I'm exporting each stored procedure as a script, by right clicking -> script stored procedure -> CREATE To -> File.
Is it possible to export all procedures at once, using a powershell script or anything else?
Use the Generate Scripts tool in SSMS:
Right Click Database in Object Explorer.
Tasks -> Generate Scripts.
If given the "tutorial" click Next.
Select "Select specific database objects" and tick "Stored Procedures". Click Next.
Choose export method. Likely here you want "Save as script file" with "one script file per object" selected. Ensure you choose the export location.
Click Next and Finish buttons as required.
If you are using MGT for MSSQL, then you follow these steps.
open MGT MSSQL and connect and open the list of databases
right button the the database where the stored procs are, this will open the con menu
go to "Tasks"
select "Generate Scripts"
select specific object, in your case, select "Stored Procedures" (you can select all or as you need)
then press "Next"
at the "Set Scripting Options" form, select the option; if you want all selected procs in one file or not, choose the directory where you want your files to be generated.
press "Next"
at the "Summary" form press "Next"
at the "Save or Publish Scripts" Press finish..
DONE.
There are advance options at step 7. to create each procs with drop and create option or just create options. go through those if you need.
tc.
I have developed a C# application that can accomplish this, scripting out all tables, views, stored procedures, functions, etc. to text files (one per object). This is very useful for scripting out the objects on a regular basis then keeping track of them in a Git repository. Download the DB Schema Export Tool from https://github.com/PNNL-Comp-Mass-Spec/DB-Schema-Export-Tool/releases
Example command line for automation:
DB_Schema_Export_Tool.exe
C:\Cached_DBSchema
/Server:Proteinseqs
/DBList:Manager_Control,Protein_Sequences
/Sync:"F:\Projects\Database_Schema\DMS"
/Git /Commit
/L /LogDir:Logs
/Data:ProteinSeqs_Data_Tables.txt
On Linux, use mono DB_Schema_Export_Tool.exe
Information on Mono
There are other command line switches available; see the Readme.
In addition to SQL Server, the software supports Postgres. Example output files can be found at https://github.com/PNNL-Comp-Mass-Spec/DBSchema_DMS/tree/master/DMS_Pipeline

Sql Azure Export to CSV

I am trying to export Sql Azure table to CSV. When I right click on Database I see Tasks / Export Datatier application. Where Can I see the option to export data to csv from Sql Azure?
If you are using Windows 10 and have SSMS and the Client tools, you should be able to just go to the search window and type 'Import and Export Data' to find the Import and Export Data program (which is basically the SQL Server Export Wizard).
For some reason the choice doesn't show up in SSMS for Azure databases - but you can run the wizard as the stand alone app - and it works fine with Azure databases. More detail at: http://bpmdeveloper.com/sql-server-export-wizard-csv/
Here are two straight forward solutions if you are okay with pulling the csv to your working environment:
Use SSMS to query your data with quoted column names, then right click in the results window, and click 'save results as'.
The same process can be followed with Azure Data Studio, but instead of right clicking, you can click the 'save as csv' button to the right of the query results.

In SQL Server 2008 R2 script data missing on Script Wizard

In my SQL Server 2008 R2
Script Option Screen of Script Wizard under section Table/View Options Look I find Script Data row and want to turn the option to True but I fail.
I don't find any script data option. Why script data option missing on my SQL Server 2008 R2? Is there any command to generate the insert data option.
Why this problem arise? how to solve it? Thanks in advance
It looks like they removed it from that location. You can still do it by:
Right clicking on the DB
Click on tasks
Click on generate scripts
Go through the wizard and select your tables
On the options page click the Advanced button
Change the "Types of data to script" option, from the default "Schema only" to "Schema and data".
In SQL Server 2008 R2 you can go on the DB, right click on DB -> Tasks -> Generate scripts. This is the wizard for scripting the objects (with or without data). Follow the stepts described on the first page. At the third stept, "Set Scripting Options", after you choose your way to save /publish your data, you go on "Advanced" and there, for General Options, at line "Types of data to script" you can choose to script also your data ("Schema and data").

Resources