Query your SQL database in Fabric

Applies to:SQL database in Microsoft Fabric

You can query Fabric SQL database just like any other SQL Server database, using SQL Server Management Studio or the mssql extension with Visual Studio Code. Fabric SQL database also includes a lightweight, browser-based query editor that we use here.

Prerequisites

Get a quick look at the data

For lightweight queries where you just want to see the structure of a table, the type of data in the table or even what columns the table has, just select on table's name in the Object Explorer. The top 1,000 rows will automatically be returned.

If you want to write a new query with T-SQL, select the New Query button from the toolbar of the query editor.

Tip

To get a head start on the basic structure of a query, select the ... on the table name, and select SELECT TOP 1000 rows from the menu. Or, create a new query using the New SQL query dropdown list, then create T-SQL scripts with code templates that populate in your SQL query window.

Ask Copilot to write a query

Copilot can also be used to write a query, and will translate natural language prompts to T-SQL.

  1. Start with a database with some data. For example, try the AdventureWorks sample data.

  2. Select New Query in the ribbon.

  3. Type the following text as a T-SQL comment, then press the tab key:

    --I need to query order history, by count and value, grouped by customer company name   
    
  4. You should see a suggestion like this:

    Screenshot from the Fabric portal showing the results of a Copilot query suggestion on the AdventureWorksLT sample database.

  5. Press the tab key to accept the suggested T-SQL code.

  6. Review the query.

  7. Select Run from the toolbar of the query window and review the results.

For more on query capabilities with the SQL database query editor in the Fabric portal, see Query with the SQL query editor.

Next step