Checking a linked table on another server

rsaritzky
Member Posts: 469
I have a linked table on another server - it is used for inquiry only on a Navision form.
I don't want to cause an error for the user if the other SQL Server is down for any reason. They won't be able to open the linked-table form, but I don't want to crash them out of Navision.
Has anyone discovered or created any code to test if a remote SQL server is available?
Thanks
Ron
I don't want to cause an error for the user if the other SQL Server is down for any reason. They won't be able to open the linked-table form, but I don't want to crash them out of Navision.
Has anyone discovered or created any code to test if a remote SQL server is available?
Thanks
Ron
Ron
0
Comments
-
May be you can try to use replications. The data will be in sync when the server is on-line, or you will have local copy if the remote server is down... and you do not need to do any code... ;-)0
-
Trap the error in your view and return a blank record if there is an error.There are no bugs - only undocumented features.0
-
bbrown wrote:Trap the error in your view and return a blank record if there is an error.
Thx
RonRon0 -
This is an example that will return a blank record if the table does not exist in the remote database. You could do something similar to test for other conditions by querying the remote system catalogs.
IF EXISTS (Select object_id from SCALE_A.Tropical.sys.tables Where name = 'Host') SELECT PRODNUMB AS [Prod_ Order No_], PALLETNUMB AS [Container ID], ITEM AS [Item No_], LOT AS [Lot No_], SUM(QTY) AS Quantity, SUM(WEIGHT) AS [Weight from Scale] FROM SCALE_A.Tropical.dbo.Host AS Host_1 GROUP BY PRODNUMB, PALLETNUMB, ITEM, LOT ELSE SELECT '' AS [Prod_ Order No_], '' AS [Container ID], '' AS [Item No_], '' AS [Lot No_], 0 AS Quantity, 0 AS [Weight from Scale]
There are no bugs - only undocumented features.0 -
bbrown wrote:This is an example that will return a blank record if the table does not exist in the remote database. You could do something similar to test for other conditions by querying the remote system catalogs.
IF EXISTS (Select object_id from SCALE_A.Tropical.sys.tables Where name = 'Host') SELECT PRODNUMB AS [Prod_ Order No_], PALLETNUMB AS [Container ID], ITEM AS [Item No_], LOT AS [Lot No_], SUM(QTY) AS Quantity, SUM(WEIGHT) AS [Weight from Scale] FROM SCALE_A.Tropical.dbo.Host AS Host_1 GROUP BY PRODNUMB, PALLETNUMB, ITEM, LOT ELSE SELECT '' AS [Prod_ Order No_], '' AS [Container ID], '' AS [Item No_], '' AS [Lot No_], 0 AS Quantity, 0 AS [Weight from Scale]
Thanks for the sample code - I'm still not convinced that this will not return an error if the remote server is down - but I don't know for sure. I'm going to test it against a test server that I can bring down intentionally and see what happens.
RonRon0 -
Yes, this example will not cover that situation. This is covering the situation where the table does not exist. I sent this has an example from which you could derive something that works for you.There are no bugs - only undocumented features.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions