Español Practice SQL

SQL Server basics: TOP, ISNULL and LEN

Most of your SQL works in SQL Server as it is. A few everyday things are written differently.

Dialects · SQL Server

Practice this now

Free. No sign up. Your progress stays in this browser.

What you will learn

SQL Server speaks T-SQL. The biggest surprise for newcomers: there is no LIMIT.

This guide covers the top rows, empty values and text length the SQL Server way.

The basics

SQL Server speaks T-SQL. Most of what you learned works as is; a few things are written differently.

SELECT TOP 5 customer, amount
FROM invoices
ORDER BY amount DESC

TOP goes right after SELECT. There is no LIMIT. For paging, SQL Server has OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY after ORDER BY.

Empty values and text

SELECT customer, ISNULL(paid_date, 'Not paid') AS paid, LEN(customer) AS name_length
FROM invoices

ISNULL(value, fallback) is SQL Server’s two argument COALESCE. LEN counts characters and ignores spaces at the end. Names with spaces go in square brackets: [order date].

Worked examples

Example 1

The five largest invoices.

SELECT TOP 5 customer, amount
FROM invoices
ORDER BY amount DESC

TOP goes right after SELECT.

Example 2

Show “None” for empty paid dates.

SELECT customer, ISNULL(paid_date, 'None') AS paid
FROM invoices

ISNULL takes exactly two arguments.

Reading helps, typing makes it stick. Every task gives you a fresh table, and your query is checked by a real database.

Try a task

Common mistakes

  • Writing LIMIT at the end, which SQL Server does not know.
  • Using LENGTH instead of LEN.
  • Grouping by a column alias, which SQL Server refuses.

Where you will use it at work

  • Finance teams on Microsoft stacks.
  • Reports built in SQL Server Reporting Services or Power BI.
  • Operations databases behind ERP systems.

Questions people ask

Is T-SQL the same as SQL Server?

T-SQL is the language; SQL Server and Azure SQL are the products that speak it.

How do I page results?

ORDER BY ... OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY.

Does SQL Server have ||?

SQL Server 2025 adds it. Older versions use + or CONCAT().

Ready to write it yourself?

Practice TOP, ISNULL and LEN

Further reading

Related guides

SQL Practice is independent and not affiliated with the maker of this database. The exercises run on SQLite in your browser and imitate this dialect’s syntax for practice.