0% found this document useful (0 votes)
6 views20 pages

Intro to SQL for Microsoft SQL Server

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
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views20 pages

Intro to SQL for Microsoft SQL Server

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
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Connect Learn Share

Beginning SQL
Microsoft SQL Server Introductory SQL
Presented by:

Britton Lowry, MCP, CPIM


Kraft Enterprise Systems, LLC
blowry@[Link]

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 [Link], [Link], [Link],
COUNT([Link])
FROM RM00301 S
INNER JOIN RM00101 R ON [Link] = [Link]
GROUP BY [Link], [Link], [Link]
ORDER BY [Link], [Link]
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 [Link], [Link], [Link],
SUM([Link]) AS 'QTY'
FROM SOP30200
inner Join SOP30300 on [Link] = [Link]
WHERE Year([Link]) = '2017'
AND [Link] = 3
GROUP BY [Link], [Link], [Link]
Questions
RESOURCES

• Victoria Yudin – SQL Coding Tips


[Link]
• [Link] – GP SQL Scripts
[Link]
THANK YOU!
Britt Lowry, CPIM, MCP
Chief Technologist | blowry@[Link]
Office 615-665-2545 x 105 | Cell 615-969-8255 |

You might also like