sql and support debugging tool paul johnson and graham o’bray

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

Post on 26-Dec-2015

212 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • Slide 1
  • SQL and Support Debugging Tool Paul Johnson and Graham OBray
  • Slide 2
  • Whats 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
  • Slide 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
  • Slide 4
  • Safe Query Development Rogue SQL Queries Minimize impact on production databases TOP N Clause WITH (NO LOCK) WHERE clause
  • Slide 5
  • Joins and Table Aliases Table aliases Provide plain language reference Easier to understand, follow scripts Simplifies joins Can also use field aliases
  • Slide 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
  • Slide 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%
  • Slide 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 * FROMWHERE =)
  • Slide 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
  • Finding Tables and Fields Inside GP, click: Tools > Resource Descriptions Support debugging tool: Tools > Support Debugging Tool Debugger Menu > Resource Information SQL Management Studio
  • Slide 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)
  • Slide 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
  • Slide 26
  • Finding GP data using SDTL Use the Resource information menu in the support debugging tool
  • Slide 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
  • Slide 28
  • Audit security Security Profiler Security Information
  • Slide 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
  • Slide 30
  • Q&A Thanks for Attending http://www.prophet.ca/user-group-2014-presentations/ Paul Johnson paulj@prophet.ca Password: UserGroup2014