SQL View

bjerris
Member Posts: 3
Hi
I've created a view in SQL 2008 SP2 for usage in Navision 6.01. The view actually works, but I'm not sure that I've designed the view correctly. The main idea is to create a customer list which also shows the balance of the customer. When I created it in Navision it was very slow, but with this it's quite fast. Any cents?
SELECT
dbo.[CRONUS Danmark A_S$Customer].No_ AS [Customer No_],
dbo.[CRONUS Danmark A_S$Customer].Name AS [Customer Name],
dbo.[CRONUS Danmark A_S$Customer].[Responsibility Center],
dbo.[CRONUS Danmark A_S$Customer].[Location Code],
dbo.[CRONUS Danmark A_S$Customer].[Phone No_],
dbo.[CRONUS Danmark A_S$Customer].Contact,
dbo.[CRONUS Danmark A_S$Customer].[Search Name],
SUM(dbo.[CRONUS Danmark A_S$Detailed Cust_ Ledg_ Entry$VSIFT$4].SUM$Amount) AS Amount
FROM
dbo.[CRONUS Danmark A_S$Customer] INNER JOIN dbo.[CRONUS Danmark A_S$Detailed Cust_ Ledg_ Entry$VSIFT$4] ON
dbo.[CRONUS Danmark A_S$Customer].No_ = dbo.[CRONUS Danmark A_S$Detailed Cust_ Ledg_ Entry$VSIFT$4].[Customer No_]
GROUP BY
dbo.[CRONUS Danmark A_S$Customer].No_,
dbo.[CRONUS Danmark A_S$Customer].Name,
dbo.[CRONUS Danmark A_S$Customer].[Responsibility Center],
dbo.[CRONUS Danmark A_S$Customer].[Location Code],
dbo.[CRONUS Danmark A_S$Customer].[Phone No_],
dbo.[CRONUS Danmark A_S$Customer].Contact,
dbo.[CRONUS Danmark A_S$Customer].[Search Name]
I've created a view in SQL 2008 SP2 for usage in Navision 6.01. The view actually works, but I'm not sure that I've designed the view correctly. The main idea is to create a customer list which also shows the balance of the customer. When I created it in Navision it was very slow, but with this it's quite fast. Any cents?
SELECT
dbo.[CRONUS Danmark A_S$Customer].No_ AS [Customer No_],
dbo.[CRONUS Danmark A_S$Customer].Name AS [Customer Name],
dbo.[CRONUS Danmark A_S$Customer].[Responsibility Center],
dbo.[CRONUS Danmark A_S$Customer].[Location Code],
dbo.[CRONUS Danmark A_S$Customer].[Phone No_],
dbo.[CRONUS Danmark A_S$Customer].Contact,
dbo.[CRONUS Danmark A_S$Customer].[Search Name],
SUM(dbo.[CRONUS Danmark A_S$Detailed Cust_ Ledg_ Entry$VSIFT$4].SUM$Amount) AS Amount
FROM
dbo.[CRONUS Danmark A_S$Customer] INNER JOIN dbo.[CRONUS Danmark A_S$Detailed Cust_ Ledg_ Entry$VSIFT$4] ON
dbo.[CRONUS Danmark A_S$Customer].No_ = dbo.[CRONUS Danmark A_S$Detailed Cust_ Ledg_ Entry$VSIFT$4].[Customer No_]
GROUP BY
dbo.[CRONUS Danmark A_S$Customer].No_,
dbo.[CRONUS Danmark A_S$Customer].Name,
dbo.[CRONUS Danmark A_S$Customer].[Responsibility Center],
dbo.[CRONUS Danmark A_S$Customer].[Location Code],
dbo.[CRONUS Danmark A_S$Customer].[Phone No_],
dbo.[CRONUS Danmark A_S$Customer].Contact,
dbo.[CRONUS Danmark A_S$Customer].[Search Name]
0
Comments
-
If it's working then it's correct. If you like experimentig you can try a subselect statement like:
select [No_], [Name], ( select sum(Amount) from dbo.[xxxdb$Detailed Cust_ Ledg_ Entry] as dcle group by [Customer No_] having cs.[No_] = dcle.[Customer No_] ) as Amount from dbo.Customer as cs
I don't know which one's faster...0 -
Hi kapamarou
The customer has a lot cust. ledg. entries, and thats why I had to make an SQL view and use that in Navision (via linked objects) instead of a flowfield in customer list form.0 -
The flowfield should be fast to calculate. There must be something else going on... Maybe disabled keys, a hotfix missing... I wouldn't use SQL view for such tasks...Maybe you should investigate this more. Have you used client monitor or profiler to see what is sent to SQL and why it is delaying?0
-
What object version are you using, and what build is this?
The flow field should not be slow, it's generating the data that is slow. It looks (as stated above) that someone has broken something.David Singleton0
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