Creating a basic SQL query
It all starts with a query. This recipe will show you how to retrieve data from tables in the database.
How to do it...
Open SQL Server Management Studio and connect to the server that holds your NAV database.
Click on the New Query button.
Select your NAV database in the database dropdown.
Enter the following code in the window:
SELECT [No_], [Name], [Address], [City], [County], [Post Code] FROM [CRONUS USA, Inc_$Customer] WHERE [No_] = '10000'
Press F5 to run the query.
You should see the following results:
How it works...
This is a basic SQL query made up of three basic parts. The first is the SELECT
line, which tells the system the names of the fields we want to retrieve. We surround the field names with brackets, [ ], because a lot of times the name of the field is also a reserved keyword or a space. The brackets are not mandatory for every field, but it makes it simpler to add them every time. Notice also that in NAV the customer number is stored in a field named...