Accessing and Changing Data Fundamentals

The primary purpose of a Microsoft® SQL Server™ database is to store data and then make that data available to authorized applications and users. While database administrators create and maintain the database, users work with the contents of the database:

Accessing and changing data in Microsoft® SQL Server™ is accomplished by using an application or utility to send data retrieval and modification requests to SQL Server. For example, you can connect to SQL Server using SQL Server Enterprise Manager, SQL Server Query Analyzer, or the osql utility and begin working with the data in SQL Server.

Applications and utilities use two components to access SQL Server:

These four statements form the core of the SQL language. Understanding how these four statements work is a large part of understanding how SQL works.

Graphical or forms-based query tools require no knowledge of SQL. They present the user with a graphical representation of the table. The user can graphically select the columns to be retrieved and easily specify how to qualify the rows to be retrieved.

Some applications, such as SQL Server Query Analyzer and the osql utility, are tools for executing Transact-SQL statements. The tools execute Transact-SQL statements entered interactively or read from a file. To use these tools, you must be able to build Transact-SQL statements.

Applications written to the general-purpose database APIs, such as ADO, OLE DB, ODBC, or DB-Library, also send Transact-SQL statements to SQL Server. These applications present the user an interface reflecting the business function they support. When the user has indicated what business function should be performed, the application uses one of the database APIs to pass SQL statements to SQL Server. You must be able to build Transact-SQL statements to code these types of applications.

Other applications, such as SQL Server Enterprise Manager, use an object model that increases efficiency in using SQL Server. SQL Server Enterprise Manager uses an object model that eases the task of administering SQL Servers. APIs such as SQL-DMO, SQL-DTS, and the replication components also use similar object models. The objects themselves, however, communicate with SQL Server using Transact-SQL. Knowing the Transact-SQL language can help you understand these objects.

Building Transact-SQL Statements

Accessing and Changing Fundamentals contains information about the basic elements used to build Transact-SQL statements. It also provides information about the functions Transact-SQL can perform, as well as similar functionality offered by the database APIs.

A SELECT statement contains the common elements used in Transact-SQL statements. For example, to select the names, contact names, and telephone numbers of customers who live in the USA from the Customers table in the Northwind database, these elements are used:

This is the Transact-SQL syntax to retrieve this information:

SELECT CompanyName, ContactName, Phone

FROM Northwind.dbo.Customers

WHERE Country = 'USA'

  

Additional elements used in Transact-SQL statements include:

See Also
Data Types CREATE TABLE
Expressions ALTER TABLE
Using Identifiers Operators
Functions  

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.