Previous Page
Next Page

1.10. Entering a SQL Query or Statement

Like every computer language, a SQL query or statement is used to give instructions to the computer. A query is a request for data stored in SQL Server. The computer analyzes each instruction and interprets it. If the instruction is "understandable" to the computer, the computer produces a result. If the computer cannot figure out what the instruction means, it displays an error message.

In this book, we focus on Transact-SQL (T-SQL), SQL Server's variant of SQL. In SQL Server , the SQL query is typed in the query editor screen, as shown in Figure 1-12. But, before you type in your query, make sure the database that you wish to work with is active or open. To type in or work on the queries in this book, the Student_course database should be active or open.

Right click on Student_course and then select New Query. Type the following SQL query in the resulting screen:

    USE Student
    SELECT *
    FROM Student

USE Student opens the Student_course database, as shown in Figure 1-12. SELECT is the SQL keyword that means "select data" or "retrieve the following data from the database." The * is interpreted to mean "show all columns in the result." FROM is the keyword that names the source of the data, and Student is the name of a table. So this is a simple SQL query that tells SQL Server to display all the rows and columns (all the data) in the Student table.


Previous Page
Next Page