chapter 2: ms sql server

20
Advanced Programming Methodology in C# - Database

Upload: ngeam-soly

Post on 05-Dec-2014

709 views

Category:

Education


7 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Chapter 2: Ms SQL Server

Advanced Programming Methodology in C# - Database

Page 2: Chapter 2: Ms SQL Server

MS SQL Server

Page 3: Chapter 2: Ms SQL Server

Contents

Before we go through to ADO.NET we need to understand some basic of Database. For this course we will use MS SQL Server as DBMS to illustrate any practice. Here below are key points need to understand in this chapter :•MS SQL Server• SQL Statements

Page 4: Chapter 2: Ms SQL Server

MS SQL Server

Microsoft SQL Server is a relational database management system developed by Microsoft. As a database, it is a software product whose primary function is to store and retrieve data as requested by other software applications, be it those on the same computer or those running on another computer across a network (including the Internet).

Page 5: Chapter 2: Ms SQL Server

MS SQL Server (Cont.)

There are at least a dozen different editions of Microsoft SQL Server aimed at different audiences and for different workloads (ranging from small applications that store and retrieve data on the same computer, to millions of users and computers that access huge amounts of data from the Internet at the same time).

Page 6: Chapter 2: Ms SQL Server

MS SQL Server (Cont.)

There are several editions of MS SQL Server:• Datacenter• Enterprise• Standard• Web• Business Intelligence• Workgroup• Express

Page 7: Chapter 2: Ms SQL Server

MS SQL Server - Authentication

Page 8: Chapter 2: Ms SQL Server

MS SQL Server – Create Database

Page 9: Chapter 2: Ms SQL Server

MS SQL Server – Create Table

Page 10: Chapter 2: Ms SQL Server

MS SQL Server – Open Table

Page 11: Chapter 2: Ms SQL Server

MS SQL Server – Query Editor

Page 12: Chapter 2: Ms SQL Server

MS SQL Server – Query Editor

Page 13: Chapter 2: Ms SQL Server

SQL StatementsBasic SQL Statements is divided into two main types; Data Definition Language (DDL) and Data Manipulation Language (DML). Here below are important statements that need to understand in order to learn this subject:• CREATE TABLE (DDL)• SELECT (DML)• INSERT (DML)• UPDATE (DML)•DELETE (DML)

Page 14: Chapter 2: Ms SQL Server

SQL Statements – CREATE TABLECREATE TABLE MySqlTable( Name varchar(10) Not Null, Age int, SSN varchar(11), Date datetime, Gender char(6))

Page 15: Chapter 2: Ms SQL Server

SQL Statements - SELECT

Select * from <table name>Select <column>, <column>, … from <table name>

Select * from PersonAddressSelect AddressID, AddressLine1, City from PersonAddress

Page 16: Chapter 2: Ms SQL Server

SQL Statements – SELECT (Cont.)Select <column>, <column>, … from <table name>WHERE <columnl> <operator> <column2 / Value>

Select AddressID, AddressLine1, City from PersonAddressWHERE City = ‘Redmond’

Page 17: Chapter 2: Ms SQL Server

SQL Statements - INSERTINSERT INTO <table>(<column1>, <column2>, ..., <columnN>)VALUES (<value1>, <value2>, ..., <valueN>)

insert into MySqlTable( Name, Age, SSN, Date, Gender )Values('Vidya Vrat',36,'111-20-3456',GetDate(),'Male')

Page 18: Chapter 2: Ms SQL Server

SQL Statements - UPDATE

UPDATE <table>SET <columnl> = <valuel>,<column2> = <value2>, ..., <columnN> = <valueN>

update MySqlTableset Name = 'Pearly'where Id = 3

Page 19: Chapter 2: Ms SQL Server

SQL Statements - DELETE

DELETE FROM <table>WHERE <predicate>

delete from MySqlTablewhere Id = 2

Page 20: Chapter 2: Ms SQL Server

Summary

What you learn from this chapter are:

o What is MS SQL Server and how many editions

does it has

o How to configure MS SQL Server

o Understand basic SQL Statement:• CREATE TABLE

• SELECT

• INSERT

• UPDATE

• DELETE