Search⌘ K
AI Features

Guidelines for Writing Query

Explore practical guidelines for writing clear and efficient SQL queries using Transact-SQL in SQL Server. Learn how formatting, comments, indentation, and delimited identifiers improve code readability and maintenance, helping you write better data retrieval commands and troubleshoot with ease.

Here are the basic guidelines we should follow when writing SQL statements. We don’t necessarily have to learn a whole bunch of commands, but just learning their purpose will be good enough. If we understand how the INSERT statement works and how we can use it, we can apply this across many aspects of SQL Server.

Format

In this course we will be using Transact SQL (T-SQL) for writing SQL queries. T-SQL is different from other coding languages in how the database engine interprets its syntax.

For example, the database engine doesn’t care if our code is uppercase, lowercase, or in the same line. It will read the syntax from left to right and top to bottom.

Look at the coding example below. ...