






















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An introduction to sql and t-sql, the structured query language and its transact-sql implementation in sql server. It covers the fundamental operations of creating, retrieving, updating, and deleting data in sql server databases. The basic syntax and capabilities of the select statement for querying data, including filtering, sorting, and using aliases. It also demonstrates how to insert, update, and delete data using the insert, update, and delete statements. Additionally, the document discusses the use of views to simplify complex queries and manage data access. Suitable for students, developers, and database administrators who are new to sql server and want to learn the essential crud operations.
Typology: Exams
1 / 30
This page cannot be seen from the preview
Don't miss anything!























SELECT FirstName, LastName, JobTitle FROM Employees
SELECT FirstName, LastName, JobTitle FROM Employees INSERT INTO Projects(Name, StartDate) VALUES('Introduction to SQL Course', '1/1/2006') SELECT * FROM Projects WHERE StartDate = '1/1/2006' UPDATE Projects SET EndDate = '8/31/2006' WHERE StartDate = '1/1/2006' DELETE FROM Projects WHERE StartDate = '1/1/2006'
Selection
Projection
Table 1 (^) Table 2 Join
▪ Aliases rename a table or a column heading ▪ You can shorten fields or clarify abbreviations
SELECT EmployeeID AS ID, FirstName, LastName FROM Employees ID FirstName LastName 1 Guy Gilbert 2 Kevin Brown … … … SELECT c.Duration, c.ACG AS 'Access Control Gateway' FROM Calls AS c Display Name
▪ You can concatenate column names using the + operator ▪ String literals are enclosed in single quotes ▪ Column names containing special symbols use brackets
SELECT FirstName + ' ' + LastName AS [Full Name], EmployeeID AS [No.] FROM Employees Full Name No. Guy Gilbert 1 Kevin Brown 2 … …
SELECT FirstName + ' ' + LastName AS [Full Name], JobTitle, Salary FROM Employees Concatenation Column Alias
▪ NULL is a special value that means missing value ▪ Not the same as 0 or a blank space ▪ Checking for NULL values
SELECT LastName, ManagerId FROM Employees WHERE ManagerId IS NULL SELECT LastName, ManagerId FROM Employees WHERE ManagerId IS NOT NULL SELECT LastName, ManagerId FROM Employees WHERE ManagerId = NULL This is always false!
▪ ASC: ascending order, default ▪ DESC: descending order SELECT LastName, HireDate FROM Employees ORDER BY HireDate LastName HireDate Gilbert 1998 - 07 - 31 Brown 1999 - 02 - 26 Tamburello 1999 - 12 - 12 … … SELECT LastName, HireDate FROM Employees ORDER BY HireDate DESC LastName HireDate Valdez 2005 - 07 - 01 Tsoflias 2005 - 07 - 01 Abbas 2005 - 04 - 15 … …
▪ Name the view v_HighestPeak
CREATE VIEW v_HighestPeak AS SELECT TOP (1) * FROM Peaks ORDER BY Elevation DESC Greatest value first Sorting column