Snowflake Extension for Visual Studio Code

Snowflake provides an extension for Visual Studio Code (VS Code) to enable Snowflake users to write and execute Snowflake SQL statements directly in VS Code. Extensions are pre-packaged functionality, often provided by third parties, which add new features and functionality to VS Code.

In this Topic:

Installing the Snowflake Extension for Visual Studio Code

Snowflake users can install the VS Code extension directly from the Visual Studio marketplace, or download the extension, packaged as a .xsix file, and then install.

Installing from the Visual Studio Marketplace

To install directly from the Visual Studio Marketplace, do the following:

  1. Open Visual Studio Code.

  2. Select Code » Preferences » Extensions.

    You can also select View » Extensions or click the extensions button vsc-extensions-button in the VS Code Activity Bar.

  3. In the Search Extensions text box, enter the text Snowflake to search for the Snowflake Visual Studio Extension.

  4. From the set of extensions, select the extension authored by Snowflake and click Install.

Installing from a .vsix file

To download and install from a .vsix file, do the following:

  1. Download the extension.

    1. Open the page Snowflake Visual Studio Code extension.

    2. Select the Version History tab.

    3. Select a version to download and click Download. Note where the file is downloaded.

  2. Open Visual Studio Code.

  3. Select Code » Preferences » Extensions.

    You can also select View » Extensions or click the extensions button vsc-extensions-button in the Activity Bar.

  4. Select Install from VSIX from the more(…) menu.

    In the Extensions page, select more and then Install from VSIX file.
  5. Locate the snowflake-x.y.z.vsix file on your computer, select the file, and then select Install.

After the installation completes, the Snowflake Extension for Visual Studio Code appears in the INSTALLED section of the Extensions menu in VS Code.

The Snowflake SQL extension, after being installed in Visual Studio Code.

Signing In

Before you can execute SQL statements you must sign into a Snowflake account.

You can sign into Snowflake using your Snowflake account identifier, username, and password, or using federated authentication to Snowflake using SAML SSO.

The first time you sign into Snowflake from the VS Code extension, you need to add your account by entering either the account identifier for your Snowflake account or the URL that you use to connect to Snowflake.

See Account Identifiers for details on how to determine your account identifier.

To sign into Snowflake from the VS Code extension, do the following:

  1. In the Activity Bar, click the Snowflake icon.

    The side bar panel changes to Snowflake navigation, and displays the Add Account or Sign in dialogs.

  2. Under Add Account, enter either the account identifier, and elect Continue.

    Add Account is only displayed if no account was previously specified.

    The Snowflake select account dialog.
  3. Enter a username and password for the selected account and select Sign in.

On successful sign in, the sidebar changes to display the session context (ACCOUNT), DATABASE EXPLORER for the user in their default role, and QUERY HISTORY.

Working with SQL Files

You can use the Snowflake Extension for Visual Studio Code to create and load SQL files. SQL files are simple text files that contain one or more SQL statements.

Opening SQL Files

To create or open Snowflake SQL files, do the following:

  1. Select File » Open, navigate to and open a text file containing SQL.

    If you don’t have an existing SQL file, you can create a new one. Select File » New File and create a file of type Snowflake SQL File.

  2. Add one or more Snowflake SQL statements to the file.

  3. Select a line and press [enter], above the line, to execute the command.

Executing Commands or Queries

To execute one or more commands or queries, do the following:

  1. Select a line to run by placing your cursor on the statement to be run.

    Select two or more commands - All selected commands will be executed.

  2. Press the [enter] button above the first command selected.

If you select multiple commands, the commands execute in order from top to bottom.

You can also run statements using keyboard shortcuts. After selecting the SQL statements you want to run, press Apple OSX Command key. + [enter] on a Mac keyboard, or Generic control key. + [enter] on a Windows keyboard.

You can see the results of the SQL statement in the SNOWFLAKE:QUERY RESULTS table of the Output section.

Using Query History

Query results are tracked in QUERY HISTORY.

To display query results, do the following:

  1. Expand Query History.

  2. Select a statement.

  3. Examine the result in the SNOWFLAKE:QUERY RESULTS tab of the Output pane.

Example of executing a statement with result highlighted.

Tip

You can use the Query History to rerun a query(vsc-query-rerun-button), copy the query text to the clipboard(vsc-query-copy-button), or delete a query (vsc-query-delete-button).

Changing Session Context

You can use the Account section of the Side Bar panel to select roles, databases, schemas, and warehouses. Use the associated dropdown to select each as appropriate.

The Snowflake sign in dialog.

Tip

Use the account drop down to sign into, or switch between different accounts.

Sign in to, or switch between accounts.

View Extension Details

You can view the Snowflake SQL Visual Studio Code extension information at any time.

You can see the following details about the extension, including:

  • Version information: Which version of the extension is currently installed.

  • Changelog: Information by version about features added, changed, or updated.

  • Feature walkthroughs.

In addition, you can disable or enable the extension using the enabled/disable dropdown.

To view extension information, do the following:

  1. Select Code » Preferences » Extensions.

  2. Select the Snowflake VS Code SQL extension.

    You can also select View » Extensions or click the extensions button vsc-extensions-button in the Activities bar.

Uninstalling the Extension

To disable or uninstall the extension, do the following:

  1. Select Code » Preferences » Extensions

  2. Select the extension.

  3. Right-click and choose Disable or Uninstall.

Back to top