1 Working with MS SQL Server Textbook Chapter 14.

Slides:



Advertisements
Similar presentations
Database Basics. What is Access? Database management system Computer-based equivalent of a manual database Makes it easy to organize and update information.
Advertisements

CC SQL Utilities.
1 After completing this lesson, you will be able to: Create a database. Create a table using the Table Wizard. Create and modify a table in Design view.
Microsoft Excel 2003 Illustrated Complete Excel Files and Incorporating Web Information Sharing.
Access - Project 1 l What Is a Database? –A Collection of Data –Organized in a manner to allow: »Access »Retrieval »Use of That Data.
Exploring Microsoft Excel 2002 Chapter 7 Chapter 7 List and Data Management: Converting Data to Information By Robert T. Grauer Maryann Barber Exploring.
Let’s try Oracle. Accessing Oracle The Oracle system, like the SQL Server system, is client / server. For SQL Server, –the client is the Query Analyser.
Introduction to Structured Query Language (SQL)
Introduction to Structured Query Language (SQL)
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Concepts of Database Management Sixth Edition
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Chapter Extension 6 Using Microsoft Access © 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke.
Microsoft Access 2010 Chapter 7 Using SQL.
 Pages made using data in a database  Use scripting languages  Use of RDMS  Look and feel by templates, CSS  High scaling  Admin pages as back end.
Working with SharePoint Document Libraries. What are document libraries? Document libraries are collections of files that you can share with team members.
Business Computer Information Systems Microsoft Office XP Access Review Lessons 1 through 5.
1 Working with MS SQL Server II. 2 The sqlcmd Utility Command line utility for MS SQL Server databases. Previous version called osql Available on classroom.
1 Working with MS SQL Server. 2 Objectives You will be able to Use Visual Studio for GUI based interactive access to a Microsoft SQL Server database.
CSCI 6962: Server-side Design and Programming
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Databases and LINQ Visual Basic 2010 How to Program 1.
ASP.NET Programming with C# and SQL Server First Edition
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
1 Lesson 22 Getting Started with Access Essentials Computer Literacy BASICS: A Comprehensive Guide to IC 3, 3 rd Edition Morrison / Wells.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
DAY 14: ACCESS CHAPTER 1 Tazin Afrin October 03,
Chapter 15: Using LINQ to Access Data in C# Programs.
Creating a Web Site to Gather Data and Conduct Research.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with MSSQL Server Code:G0-C# Version: 1.0 Author: Pham Trung Hai CTD.
Lesson 17 Getting Started with Access Essentials
Installing and Using MySQL and phpMyAdmin. Last Time... Installing Apache server Installing PHP Running basic PHP scripts on the server Not necessary.
Relational Databases (MS Access)
Microsoft Access You will need a pen/pencil.. What is Microsoft Access? Access is a database management system.  Create a database, add/change delete.
Key Applications Module Lesson 21 — Access Essentials
Concepts of Database Management Seventh Edition
Chapter 17 Creating a Database.
11 3 / 12 CHAPTER Databases MIS105 Lec15 Irfan Ahmed Ilyas.
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
ASP.NET The Clock Project. The ASP.NET Clock Project The ASP.NET Clock Project is the topic of Chapter 23. By completing the clock project, you will learn.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
McGraw-Hill/Irwin The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Lab 6 Creating and Using Lists and.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
Microsoft Access. Microsoft access is a database programs that allows you to store retrieve, analyze and print information. Companies use databases for.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
Planning & Creating a Database By Ms. Naira Microsoft Access.
Ennis-Cole, AC 2.01, CECS Maintaining A Database By: Dr. Ennis-Cole.
1 Getting Started with C++ Part 1 Windows. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Microsoft.
Microsoft Office 2013 Try It! Chapter 4 Storing Data in Access.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
1 Connecting to a Database Server. 2 We all have accounts, with a single database each, on a Microsoft SQL Server on the USF network: allman.forest.usf.edu.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
1 Working with MS SQL Server Beginning ASP.NET in C# and VB Chapter 12.
SSMS SQL Server Management System. SQL Server Microsoft SQL Server is a Relational Database Management System (RDBMS) Relational Database Management System.
Chapter 9 Working with Databases. Copyright © 2011 Pearson Addison-Wesley Introduction In this chapter you will learn: – Basic database concepts – How.
VOCAB REVIEW. A field that can be computed from other fields Calculated field Click for the answer Next Question.
Software-Projekt 2008 Seminarvortrag“Short tutorial of MySql“ Wei Chen Verena Honsel.
Copyright © 2014 Pearson Canada Inc. Ext. 5b-1 Copyright © 2014 Pearson Canada Inc. Application Extension 5b Using Microsoft Access Part 2: Using Information.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
Visual Basic 2010 How to Program
Practical Office 2007 Chapter 10
Data Definition and Data Types
Chapter 8 Working with Databases and MySQL
CIS16 Application Programming with Visual Basic
Tutorial 7 – Integrating Access With the Web and With Other Programs
Presentation transcript:

1 Working with MS SQL Server Textbook Chapter 14

2 Objectives You will be able to Use Visual Studio for GUI based interactive access to a Microsoft SQL Server database. Populate a table with data from an Excel worksheet. Use sqlcmd for command line interactive access to a Microsoft SQL Server database. Using either Visual Studio or sqlcmd to: Create and delete tables. Insert new rows into tables. Modify table definitions. Modify existing rows. Retrieve and display table data.

3 We all have accounts, with a single database each, on a Microsoft SQL Server on the CoE network: scorpius.eng.usf.edu Classroom and lab computers can access scorpius directly. A VPN connection is required for your home computer or wireless laptop to access scorpius. or maybe not for wireless access on campus CoE Resources

4 The Database Server This is the same machine that we use as a web server. Different server software. Different user accounts. Be sure to use the username and password that you have been given for the SQL Server Same username as for the web server (wpusr xx ). Different password.

5 Using Visual Studio Visual Studio includes database access functions. View "Server Explorer" Set up a Data Connection Visual Studio 2010 will not work with scorpius. The database server version on scorpius is too old! We have to use Visual Studio 2008.

6 Download Visual Studio 2008 If you don't have Visual Studio 2008 on your computer, you can get a free 90 day trial from Microsoft. Very large download!.iso file Can't be installed directly. Must use Virtual CD program or burn a real CD See OR

7 Adding a Data Connection in Visual Studio 2008 Right click on Data Connections and select Add Connection.

8 Adding a Data Connection in Visual Studio 2008 You will see this the first time you add a data connection.

9 Adding a Data Connection Your SQL Server Username Your SQL Server Password

10 Test the Connection Click here

11 Adding a Table We will add a table to the database. Populate the table with data from an Excel spreadsheet. Define the table in Visual Studio. Download the table as a CSV file. Open the spreadsheet in Excel. Copy the spreadsheet data in Excel. Paste the data into the database table in Visual Studio. Modify the table definition to add a unique ID column.

12 The Addresses Table We will create a new table to hold the addresses in file Addresses.csv. File Addresses.csv

13 Adding a Table

14 Adding a Table

15 Data Types Common SQL Data Types int nvarchar(n)n = max number chars char(n)n = number chars decimal (p,s)p = total number of digits s = number decimal places datetime Many more!

16 Define the Columns

17 Save the Table Definition Save

18 Table "Addresses" is Now Present

19 Viewing Table Data Right click on Addresses and select “Show Table Data”.

20 Viewing Table Data Table is currently empty.

21 Populating a Table Download file Addresses.csv from the Downloads area of the class web site: Double click to open in Excel

22 Excel Worksheet

23 Populating the Database Table We will use the contents of this Excel worksheet to populate the Address table in the database. Click inside the worksheet, then press Ctrl-A to select all. Press Ctrl-C to copy the entire worksheet to the clipboard.

24 Populating the Database Table Click here to select all of the table. Press Ctrl-V to paste the clipboard into the table. (This may take a while to complete.)

25 Setting an ID Field It is good practice to include an ID field for every row of a database table. Unique identifier Normally an Identity column. Value set by server as each row is added Not present in the Excel worksheet.

26 Open Table Definition Right click on Addresses and select Open Table Definition. Add column ID as int.

27 Add Column ID Select row and drag to the top.

28 Set Column Properties Make ID an identity column.

29 Set Primary Key Right click on ID and select Set Primary Key.

30 Save

31 Show Table Data End of Section

32 The sqlcmd Utility Command line utility for MS SQL Server databases. Previous version called osql Available on classroom and lab PCs. In Windows command window Connect to a Database Server Enter SQL commands on the command line. Results output to the console.

33 Getting and Installing sqlcmd Included with Management Studio Express. Free download from Microsoft In Visual Studio Help, search for sqlcmd. Or just google sqlcmd

34 The SQL Language The following slides demonstrate SQL commands using the sqlcmd program. Remember SQL is used everywhere we interact with a database server: Command line Database management programs Our own programs

35 Using sqlcmd The Server My Username Password entered here Execute commands in buffer

36 SQL Command Line Example View a subset of the columns.

37 Retrieve Specific Entries Find all addresses with zip code 33707

38 Wildcard Selection Find all addresses with last name beginning with S

39 Wildcard Selection All addresses with last name containing an s

40 Case Sensitivity SQL commands and keywords are not case sensitive. Data is case sensitive Characters are stored as upper case or lower case. Sorting order is a mode. Default is not case sensitive Search comparisons same as sorting order.

41 Case Sensitivity

42 Sorting the Output Zip_Code is a string. So sort is lexicographic, not numeric.

43 Zip Codes Zip codes are sorted legicographically, not numerically.

44 Counting Rows How many addresses are there with zip code 33707?

45 Updating Records

46 Updating Multiple Fields

47 Deleting a Record

48 SQL Commands in Visual Studio We can also use Visual Studio to issue arbitrary SQL commands to the server. On the Data menu select New Query

49 SQL Commands in Visual Studio

50 SQL Commands in Visual Studio Click here

51 SQL Commands in Visual Studio Enter SQL command here.

52 SQL Commands in Visual Studio Click here to execute the command.

53 SQL Commands in Visual Studio Results appear below the Query window.

54 Learning SQL Many books available One that I recommend: Teach Yourself SQL in 24 Hours (Third Edition) Ryan Stephens and Ron Plew, SAMS, 2003 Lots of information on the web A sampling: