SQL Fundamentals: Microsoft Enterprise Consortium

SQL Fundamentals: Microsoft Enterprise Consortium
Slide Note
Embed
Share

The basics of SQL fundamentals with the Microsoft Enterprise Consortium. Learn about SELECT statements, SQL syntax, and how to query databases using examples from AdventureWorks and Student-Teams. Get hands-on experience with MSSMS and enhance your SQL skills in a structured learning environment.

  • SQL
  • Microsoft
  • Database
  • Query
  • AdventureWorks

Uploaded on Mar 04, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Microsoft Enterprise Consortium Microsoft Enterprise Consortium Microsoft Enterprise Consortium SQL Fundamentals SELECT FROM Microsoft Enterprise Consortium: http://enterprise.waltoncollege.uark.edu Microsoft Faculty Connection/Faculty Resource Center http://www.facultyresourcecenter.com 1 Prepared by Jennifer Kreie, New Mexico State University Hosted by the University of Arkansas

  2. Microsoft Enterprise Consortium Microsoft Enterprise Consortium What you ll need For this and other SQL lessons, you need a user account from the Microsoft Enterprise Consortium. Get this account from your instructor. Log in to MEC for this lesson and into MSSMS (Microsoft SQL Server Management Studio). Be sure to select your account ID under Database in the Object Explorer pane, similar to the example shown here. 2 Prepared by Jennifer Kreie, New Mexico State University Hosted by the University of Arkansas

  3. Microsoft Enterprise Consortium Microsoft Enterprise Consortium AdventureWorks Microsoft provides an example database called AdventureWorks (AW). For the time being, only a subset of tables from this database will be used. Shown here is the data model for the HR portion of the AW database. An additional table is included from the PERSON section of the database. 3 Prepared by Jennifer Kreie, New Mexico State University Hosted by the University of Arkansas

  4. Microsoft Enterprise Consortium Microsoft Enterprise Consortium Student-Teams This database keeps information about students, the teams they are assigned to and the peer evaluations students complete for their teammates at the end of a project. 4 Prepared by Jennifer Kreie, New Mexico State University Hosted by the University of Arkansas

  5. Microsoft Enterprise Consortium Microsoft Enterprise Consortium SELECT FROM The SELECT statement has several components but let s start with only the FROM clause. A simple SELECT statement has the following format SELECT <column1>, <column2>, FROM <tablename>; The angle brackets indicate words that change depending on what data we want to see. Recommendation: Keep all the SQL commands you write for a lesson in a text file using Notepad. Do the same for SQL you write or assignments. 5 Prepared by Jennifer Kreie, New Mexico State University Hosted by the University of Arkansas

  6. Microsoft Enterprise Consortium Microsoft Enterprise Consortium Query the Student-Team database Open a Query pane (New Query). Type the SQL in Notepad then copy/paste into the query pane. Add a comment. Let s start off by seeing what teams there are. Enter two columns (teamID and team_name) in the SELECT clause. List the table name in the FROM clause. Execute the query. /* Show teams */ select teamid, team_name from teams; 6 Prepared by Jennifer Kreie, New Mexico State University Hosted by the University of Arkansas

  7. Microsoft Enterprise Consortium Microsoft Enterprise Consortium Query students & teams Query the STUDENTS table and show the ID and full name of each student. /* List students */ select stdid, stdfname, stdlname from students; Query the TEAMS table and show all columns. The asterisk is a wild card that means to show all columns without listing them by name. /* List all columns in TEAMS */ select * from teams; 7 Prepared by Jennifer Kreie, New Mexico State University Hosted by the University of Arkansas

  8. Microsoft Enterprise Consortium Microsoft Enterprise Consortium Query tables in AdventureWorks (AW) The AdventureWorks database is not in your account. To query tables in other accounts, you need to add more information to the table name in the FROM clause. In SQL below we specify the database or account name and the schema databasename.schema.tablename /* List departments in AdventureWorks */ Select DepartmentID, Name, GroupName From AdventureWorks2008.HumanResources.Department; Show information about shifts. /* List shift data AdventureWorks */ Select ShiftID, Name, StartTime, EndTime From AdventureWorks2008.HumanResources.Shift; 8 Prepared by Jennifer Kreie, New Mexico State University Hosted by the University of Arkansas

  9. Microsoft Enterprise Consortium Microsoft Enterprise Consortium Count rows in a table How many students are there? /* Count students */ select count(*) from students; How many records are there in AW s EMPLOYEE table? /* Count employee records in AW */ select count(*) from AdventureWorks2008.HumanResources.Employee; 9 Prepared by Jennifer Kreie, New Mexico State University Hosted by the University of Arkansas

  10. Microsoft Enterprise Consortium Microsoft Enterprise Consortium What was covered SELECT FROM SELECT * FROM SELECT Count(*) FROM <databasename>.<schema>.<tablename> Databasename = database or account name Schema = container of database objects 10 Prepared by Jennifer Kreie, New Mexico State University Hosted by the University of Arkansas

  11. Microsoft Enterprise Consortium Microsoft Enterprise Consortium Resources http://enterprise.waltoncollege.uark.edu/mec.asp Microsoft Faculty Connection Faculty Resource Center http://www.facultyresourcecenter.com/ Microsoft Transact-SQL Reference http://msdn.microsoft.com/en-us/library/aa299742(v=SQL.80).aspx AdventureWorks Sample Database http://msdn.microsoft.com/en-us/library/ms124659%28v=sql.100%29.aspx 11 Prepared by Jennifer Kreie, New Mexico State University Hosted by the University of Arkansas

More Related Content