Creating a basic SQL query
Let's write a very simple query to retrieve data from a table.
How to do it...
Open Microsoft SQL Server Management Studio and connect to the server that holds the NAV database.
Click on the New Query option.
Then, select the NAV database in the database dropdown.
Enter the following code in the query window:
SELECT [No_], [Name], [Address], [City], [County], [Post Code] FROM [CRONUS International Ltd_$Customer] WHERE [No_] = '10000'
Press F5 to run the query. The result should be identical to the following screenshot:
How it works...
This query is just a simple question, which has three parts: what (fields of table), from (table), and condition (filters). Using the
SELECT
keyword, we are telling the system the names of the fields we want to retrieve. Most of the time, the NAV field names contain reserved keywords or spaces. To let the system know the exact field name, we have enclosed the field names with brackets, []
. For example, we store the customer number field as...