Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL and Support Debugging Tool Paul Johnson and Graham O’Bray.

Similar presentations


Presentation on theme: "SQL and Support Debugging Tool Paul Johnson and Graham O’Bray."— Presentation transcript:

1 SQL and Support Debugging Tool Paul Johnson and Graham O’Bray

2 What’s You SQL IQ? Level 1 Select * from RM00101 Level 2 Update RM00101 set SLPRSNID=‘TOM’ where [STATE]=‘TX’ Level 3 Update c set c.COMMENT1 = dtInvCount.Invoices from RM00101 c join (Select CUSTNMBR, count(SOPNUMBE) as Invoices from SOP30200 group by CUSTNMBR) as dtInvCount on dtInvCount.CUSTNMBR = c.CUSTNMBR

3 Or are you…. Level 4 With cteCustTotals (CUSTNMBR, CUSTNAME, TotalAmount) as (Select c.CUSTNMBR, c.CUSTNAME, sum(s.DOCAMNT) as TotalAmount from RM00101 c join SOP30200 s on s.CUSTNMBR = c.CUSTNMBR and s.SOPTYPE = 3 group by c.CUSTNMBR, c.CUSTNAME) Select CUSTNMBR, CUSTNAME, TotalAmount, case when TotalAmount < 1000 then '1' when TotalAmount < 5000 THEN '2' when TotalAmount < 10000 then '3‘ when TotalAmount < 20000 then '4' when TotalAmount < 50000 then '5' else '6' end as CustLevel from cteCustTotals order by TotalAmount

4 Safe Query Development Rogue SQL Queries Minimize impact on production databases TOP N Clause WITH (NO LOCK) WHERE clause

5 Joins and Table Aliases Table aliases Provide plain language reference Easier to understand, follow scripts Simplifies joins Can also use field aliases

6 Joins and Table Aliases Combine Data from multiple tables/views with JOIN INNER LEFT OUTER RIGHT OUTER FULL OUTER CROSS JOIN Include components JOIN and ON

7 Handy SQL Keywords Comments: -- OR /* */ DISTINCT SELECT DISTINCT CUSTNMBR FROM SOP30200 RTRIM, for spaces SELECT RTRIM(CUSTNAME) AS : SELECT RTRIM(CUSTNAME) AS CUSTNAME CASE WHEN ELSE Example Later! LIKE WHERE CUSTNMBR LIKE ‘AA%’

8 Handy SQL Keywords (2) HAVING with GROUP BY GROUP BY CUSTNMBR HAVING COUNT (*) > 10 ORDER BY ORDER BY CUSTNMBER ISNULL ISNULL(ACTIDX, ‘None’) IN WHERE ACTIDX IN (3, 45, 56, 62) EXISTS WHERE EXISTS (SELECT * FROM…WHERE =)

9 Handy SQL Keywords (3) UNION Example Later! SUM, COUNT, MIN, MAX Used with GROUP BY, SUM(CUSTBLNC) BETWEEN WHERE CUSTBLNC BETWEEN 10000 AND 100000 Replaces >= and <= SELECT TOP SELECT TOP (10) PERCENT WITH TIES

10 Subqueries Query within a query or “nested” query Can be embedded in… Single Field Where Clause

11 Common Table Expressions Referred to as “CTE”s Allow you to setup complex subqueries separately Creates “tables” of information on the fly Temporary result set Nested SELECT statements Similar to a derived table but Self-reference Reference multiple times

12 More Demo Time! UPDATE with JOINS Multiple JOINS Comparisons (IN, NOT IN, WHERE NOT EXISTS) Information_Schema CASE WHEN ELSE Parameters UNION/UNION ALL PIVOT Views and Stored Procedures

13 Partition with ROWNUM ROW NUMBER allows for sequential numbering of records, RANK can be used instead for ranking OVER () stipulates the window over which the row numbering or ranking occurs PARTITION BY applies grouping without summarizing, to “reset” ranking or row numbering Can be based on a single field, or multiple fields

14 Finding Data

15 Dynamics GP Table Naming Structured as: a 2 or 3 character module code Followed by a 5 digit number Module code Ex. RM00101

16 Dynamics GP Table Naming More module code examples Payables Management – PM General Ledger – GL Inventory Control – IV

17 Dynamics GP Table Naming The first digit represents the table type Master – 0 Work – 1 Open – 2 Table History – 3 Ex. RM0010

18 Dynamics GP Table Naming The second and third digits are sequences. Sequence Number Ex. RM00101 Variants The fourth and fifth digits are variants.

19 Table Naming ModuleModule Code Cash ManagementCM General LedgerGL Inventory ControlIV InvoicingIVC Multicurrency ManagementMC Payables ManagementPM Purchase Order ProcessingPOP Receivables ManagementRM Sales Order ProcessingSOP System ManagerSM

20 Table Naming Table TypeValue Master0 Work1 Open2 History3 Setup4 Temp5 Relation6 Report Options7

21 Dynamics GP Field Naming Earlier GP versions were limited to 8 character names Ex. Customer Number – CUSTNMBR

22 Dynamics GP Views A view is a virtual table Cannot hold information, but will query tables and present data differently Can join multiple tables: Ex. Open and history

23 Finding Tables and Fields Inside GP, click: Tools > Resource Descriptions Support debugging tool: Tools > Support Debugging Tool – Debugger Menu > Resource Information SQL Management Studio

24 Data Table Resources http://victoriayudin.com/gp-tables/ Listing of commonly used tables and good explanations of fields where index numbers are used (ex. SOP Document Type: Quote = 1, Order = 2, invoice = 3)

25 Tools used to write Statements SSMS – SQL Server management studio Support debugging tool (Sql execute) Many other free tools Need to create a connection to database

26 Finding GP data using SDTL Use the Resource information menu in the support debugging tool

27 Changing Company Colours Found under administrator settings Debugger.xml file must be available to all workstations for this to work. Debugger location is set in Dex.ini setting. Under pathname location

28 Audit security Security Profiler Security Information

29 Capture screenshots Sent a copy of dex.ini, set file and system file to system admin Can reduce support costs. All users have access to this

30 Q&A Thanks for Attending http://www.prophet.ca/user-group-2014-presentations/ Paul Johnson paulj@prophet.ca Password: UserGroup2014


Download ppt "SQL and Support Debugging Tool Paul Johnson and Graham O’Bray."

Similar presentations


Ads by Google