0% found this document useful (0 votes)
35 views

Beginning SQL: Microsoft SQL Server Introductory SQL

This document provides an overview and introduction to SQL and SQL Server Management Studio (SSMS). It discusses what SQL is, how to use SSMS to navigate databases and database objects. It then covers the basics of common SQL commands like SELECT, INSERT, UPDATE, DELETE and includes examples of each. Finally, it reviews some common SQL functions like TOP, COUNT, MIN/MAX/AVG and concatenation and provides an example using these functions.

Uploaded by

Britt Lowry
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Beginning SQL: Microsoft SQL Server Introductory SQL

This document provides an overview and introduction to SQL and SQL Server Management Studio (SSMS). It discusses what SQL is, how to use SSMS to navigate databases and database objects. It then covers the basics of common SQL commands like SELECT, INSERT, UPDATE, DELETE and includes examples of each. Finally, it reviews some common SQL functions like TOP, COUNT, MIN/MAX/AVG and concatenation and provides an example using these functions.

Uploaded by

Britt Lowry
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Connect Learn Share

Beginning SQL
Microsoft SQL Server Introductory SQL
Presented by:

Britton Lowry, MCP, CPIM


Kraft Enterprise Systems, LLC
[email protected]

Prepared by:

Jeremy Kingry
eBECS LTD.
Overview
• What is SQL
• SQL Server Management Studio (SSMS)
• Standard SQL Commands (SELECT, INSERT,
UPDATE, DELETE)
• Common SQL Functions
What is SQL
• Structured Query Language (SQL)
• A special-purpose programming language
designed for managing data held in a relational
database management system (eg SQL Server)
• Standard of the American National Standards
Institute (ANSI) and International Organization
for Standardization (ISO)
SQL Server Management Studio
• Standard SQL Interface
• Hierarchical Database Navigation
• Database Objects
• SQL Database Table
• SQL Database View
SSMS Overview
SQL Commands

SELECT – Retrieve Data from Table/s or View/s


INSERT – Insert new rows into Table
UPDATE – Update Data in a Table
DELETE – Delete Row/s from a Table
SELECT

SELECT select_list
[ FROM table_source ]
[ WHERE search_condition ]
[ GROUP BY group_by_expression ]
[ ORDER BY order_expression [ ASC | DESC ] ]
SELECT Demo
--How many customer accounts per salesperson?
SELECT S.SLPRSNID, S.SLPRSNFN, S.SPRSNSLN,
COUNT(R.CUSTNMBR)
FROM RM00301 S
INNER JOIN RM00101 R ON S.SLPRSNID = R.SLPRSNID
GROUP BY S.SLPRSNID, S.SLPRSNFN, S.SPRSNSLN
ORDER BY S.SLPRSNFN, S.SPRSNSLN
INSERT

INSERT INTO table


[ (column1, column2, …….) ]
[ VALUES ]
[ (expression1, expression2, …….) ]
INSERT using a SELECT statement

INSERT INTO table


[ (column1, column2, …….) ]
SELECT expression1, expression2, …….
[ FROM table_source ]
[ WHERE search_condition ]
INSERT Demo
INSERT INTO [dbo].[SY03000]--Shipping Methods
([SHIPMTHD]
,[SHMTHDSC]
,[PHONNAME]
,[CONTACT]
,[CARRACCT]
,[CARRIER]
,[SHIPTYPE]
,[NOTEINDX]
,[LSTUSRED]
,[CREATDDT]
,[MODIFDT])
VALUES
('test',
'test',
'61596982550000',
'Britt Lowry',
'12345',
'Averett Express',
1,
0,
'sa',
'2015-05-13',
'2015-05-13')
UPDATE
UPDATE table
SET column1 = expression1
[ ,column2 = expression2 ]
[ ,…. ]
[ WHERE search condition ]
UPDATE Demo
--Unlock stuck posting batch
select * from SY00500 where BCHSTTUS <> 0 or MKDTOPST <> 0

begin tran

UPDATE SY00500
SET BCHSTTUS = 0, MKDTOPST = 0
WHERE BACHNUMB= '' --update batch number

commit
--rollback
DELETE

DELETE
FROM table
[ WHERE search condition ]
DELETE Demo
--Clear GP Locks
Delete DYNAMICS..SY00800
Delete DYNAMICS..SY00801
Delete DYNAMICS..ACTIVITY
Delete TEMPDB..DEX_LOCK
Delete TEMPDB..DEX_SESSION
COMMON SQL FUNCTIONS
TOP
COUNT(*)
MIN, MAX, AVG
CONCATENATION
IS NULL
COMMON SQL FUNCTIONS Demo
--Quantity sold for year by customer and item
SELECT SOP30200.CUSTNMBR, SOP30300.ITEMNMBR, SOP30300.ITEMDESC,
SUM(SOP30300.QUANTITY) AS 'QTY'
FROM SOP30200
inner Join SOP30300 on SOP30200.SOPNUMBE = SOP30300.SOPNUMBE
WHERE Year(SOP30200.docdate) = '2017'
AND SOP30200.SOPTYPE = 3
GROUP BY SOP30200.CUSTNMBR, SOP30300.ITEMNMBR, SOP30300.ITEMDESC
Questions
RESOURCES

• Victoria Yudin – SQL Coding Tips


http://victoriayudin.com/gp-reports/sql-server-coding-tips/
• GP-DYNAMICS.COM – GP SQL Scripts
http://www.gp-dynamics.com/dynamics-gp-tips-and-tricks.asp
THANK YOU!
Britt Lowry, CPIM, MCP
Chief Technologist | [email protected]
Office 615-665-2545 x 105 | Cell 615-969-8255 |

You might also like