I would like to have a discussion about alle the reasons for using a SQL view instead of SQL table (Normal in NAV).
Also, it would be great to name the pros and cons of using a view.
The reason i could think of using a SQL view is that
- it could give a performance boost for really big tables.
- it can be created from a subset of one or many tables
- does not hold the data itself, therefore it does not take up much space.
More reasons?
0
Comments
+To speed up the slow view, you can create an indexed view on it.
+generally easy to change something in the query without changing the table (if you don't change the type of the fields or adding/removing fields).
-native restore (if you do a native backup for some reason) can give problems. You must first create the view.
+you select only the fields you really need, so it is possible to create good indexes on the real tables the view is using, speeding up performance.
Another possibility is to create a stored procedure and run it and then read the data from it using ADO.
+the logic to get the data can be a lot more complicated than with views
-you need to run the stored procedure and then receive the data using ADO.
+native restore will not give problems (but running the query will if you didn't create the stored procedure).
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
I used this kind of integration when sending SMS (there was a separate DB with a special service) and batch terminals in the warehouse.
Follow my blog at http://x-dynamics.blogspot.com
**General pros and cons:
+ it could give a performance boost for really big tables.
+ it can be created from a subset of one or many tables
+ does not hold the data itself, therefore it does not take up much space.
+To speed up the slow view, you can create an indexed view on it.
+generally easy to change something in the query without changing the table (if you don't change the type of the fields or adding/removing fields).
+you select only the fields you really need, so it is possible to create good indexes on the real tables the view is using, speeding up performance.
- can be slow because the view is executed at the moment and (it can be a complicated query).
- native restore (if you do a native backup for some reason) can give problems. You must first create the view.
- If a NAV backup is executed the data from the dynamics nav table that uses the SQL view as a source is not included in the backup.
**Creating a stored procedure, run it and then read the data from it using ADO.
+the logic to get the data can be a lot more complicated than with views
+native restore will not give problems (but running the query will if you didn't create the stored procedure).
-you need to run the stored procedure and then receive the data using ADO.
**Using view to send and/or retrieve data from other databases
+ Communication between two or more databases
-send/receive data between different databases: if the DB are on different servers and you are using linked servers (define these in SQL Server), it is best to PULL data and not to PUSH data (meaning: read data FROM another database, but avoid writing data TO another database) because pulling data is faster than pushing data.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!