SQL server Section 2&3. What are Data Types Character Data Types Number Data Types Date and Time Data Types CAST and CONVERT functions TRY_PARSE and TRY_CONVERT.

Slides:



Advertisements
Similar presentations
This demonstration will be taking you through the new look ‘Fees’ tab in SMT.
Advertisements

MS-Access XP Lesson 1. Introduction to MS-Access Database Management System Software (DBMS) Store data in databases Database is a collection of table.
Chapter 5 Multitable Forms
Access Lesson 2 Creating a Database
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Creating And Maintaining A Database. 2 Learn the guidelines for designing databases When designing a database, first try to think of all the fields of.
Chapter Extension 6 Using Microsoft Access © 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke.
® IBM Software Group © 2006 IBM Corporation The Eclipse Data Perspective and Database Explorer This section describes how to use the Eclipse Data Perspective,
Using ER/Studio.
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Chapter 2 Querying a Database
Working with Data Types February 7, 2015 John Deardurff Website:
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 1 Committed to Shaping the Next Generation of IT Experts. Chapter 4: Create, Edit, and Perform.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Databases and LINQ Visual Basic 2010 How to Program 1.
Chapter 2 Querying a Database MICROSOFT ACCESS 2010.
Working with Queries in Microsoft Access The Access Workbench: Section Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition.
Concepts of Database Management Seventh Edition
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Lecture Note 9: Introduction to the MS Access
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.
McGraw-Hill/Irwin ©2009 The McGraw-Hill Companies, All Rights Reserved Business Driven Information Systems 2e Plug-In T6: Basic Skills and Tools Using.
CHƯƠNG 3 Finding, Filtering, and Formatting Data.
Lesson 2.  To help ensure accurate data, rules that check entries against specified values can be applied to a field. A validation rule is applied to.
Management Information Systems MS Access MS Access is an application software that facilitates us to create Database Management Systems (DBMS)
Microsoft Office 2007 Access Chapter 6 Using Macros, Switchboards, PivotTables, and PivotCharts.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 2 1 Microsoft Office Access 2003 Tutorial 2 – Creating And Maintaining A.
ISM 4212 Lab Creating DB Tables 02 copyright Lars Paul Linden 2007.
Chapter 4: Create, Edit, and Perform Calculations in Reports Exploring Microsoft Office Access 2007.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
XP New Perspectives on Microsoft Access 2002 Tutorial 1 1 Microsoft Access 2002 Tutorial 1 – Introduction To Microsoft Access 2002.
M1G Introduction to Database Development 2. Creating a Database.
Part II. Query Types On the design query table pane, right click and the cascading window will appear.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Access Project 7 Advanced Report and Form Techniques.
Microsoft Access 2010 Chapter 10 Administering a Database System.
XP New Perspectives on Microsoft Access 2002 Tutorial 1 1 Microsoft Access 2002 Tutorial 1 – Introduction To Microsoft Access 2002.
BUSINESS DRIVEN TECHNOLOGY Plug-In T5 Touring Access.
McGraw-Hill/Irwin © The McGraw-Hill Companies, All Rights Reserved TECHNOLOGY PLUG-IN T6 Basic Skills Using Access.
1 PL\SQL Dev Templates. 2 TEMPLATE DEFINITION Whenever you create a new program unit, its initial contents are based upon a template which contains pre-defined.
Introduction to Database System Adisak Intana Lecturer Chapter 7 : Data Integrity.
SQL for Database Construction and Application Processing
Session 11 Creating Tables and Using Data Types. RDBMS and Data Management/Session 11/2 of 40 Session Objectives Define the data types and list the categories.
IMS 4212: Data Manipulation 1 Dr. Lawrence West, MIS Dept., University of Central Florida Additional Data Manipulation Statements INSERT.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 25.1 Test-Driving the ATM Application 25.2.
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 1 1 Committed to Shaping the Next Generation of IT Experts. Chapter 4: Create, Edit,
Normalizing Database Files Professor Ralph Westfall May, 2011.
1 11 Exploring Microsoft Office Access 2007 Chapter 6 Data Protection.
Constraints Lesson 8. Skills Matrix Constraints Domain Integrity: A domain refers to a column in a table. Domain integrity includes data types, rules,
Session 1 Module 1: Introduction to Data Integrity
Modify Tables and FieldsModify Tables and Fields Lesson 4 © 2014, John Wiley & Sons, Inc.Microsoft Official Academic Course, Microsoft Word Microsoft.
Microsoft Office 2013 Try It! Chapter 4 Storing Data in Access.
Exploring Office 2003 Vol 1 2/e- Grauer and Barber 1 Committed to Shaping the Next Generation of IT Experts. Chapter 2- Tables and Forms: Properties, Views,
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.
Microsoft Access Prepared by the Academic Faculty Members of IT.
Ch 3. Working with Tables and Views. Data type Specify type of data to be entered into a column (text, number, datetime, etc) Unicode (National) Datatypes.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
Creating E/R Diagrams with SQL Server Management Studio, Writing SQL Queries D0ncho Minkov Telerik School Academy schoolacademy.telerik.com Technical Trainer.
Constraints Advanced Database Systems Dr. AlaaEddin Almabhouh.
What is your Character Data Type? March 5, 2016 John Deardurff Website:
Copyright © 2014 Pearson Canada Inc. Ext. 5b-1 Copyright © 2014 Pearson Canada Inc. Application Extension 5b Using Microsoft Access Part 2: Using Information.
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Data Definition and Data Types
What is your Character Data Type?
Working with Data Types
CIS16 Application Programming with Visual Basic
Access: Queries IV Participation Project
Access: Queries III Participation Project
Presentation transcript:

SQL server Section 2&3

What are Data Types Character Data Types Number Data Types Date and Time Data Types CAST and CONVERT functions TRY_PARSE and TRY_CONVERT functions. Other Data Types

Defining tables:  Ensure that SQL Server Management Studio is running.  Create Database [ApressFinancial].  Expand the Object Explorer so that you can see the ApressFinancial database.  Expand the ApressFinancial database so that you can see the Tables node, as shown in Figure.

 Right-click the Tables node and select New Table. This will take you into the Table Designer. Figure shows how the Table Designer looks when you first enter it.  From this screen, you need to enter the details for each column within the table. Enter the first column, CustomerId, in the Column Name column. When naming columns, try to avoid using spaces. Either keep the column names without spaces, like I have done with CustomerId, or use an underscore (_) instead of a space.  At the moment, notice that Column Properties in the middle of Figure is empty. This will fill up when you start entering a data type after entering the column name. The Column Properties section is just as crucial as the top half of the screen where you enter the column name and data type.  The drop-down combo box that lists the data types is one of the first areas provided by SQL Server to help us with table creation.

SQL Server associates columns, expressions, variables, and parameters with data types Data types determine what kind of data can be held: Integers, characters, dates, money, decimals, etc.

1 byte per char 2 bytes per char

Older versions of SQL Server supported only DATETIME and SMALLDATETIME DATE, TIME, DATETIME2, and DATETIMEOFFSET introduced in SQL Server 2008 SQL Server doesn't offer an option for entering a date or time value explicitly – Dates and times are entered as character literals and converted explicitly or implicitly For example, CHAR converted to DATETIME due to precedence

 When building table definitions, there can be columns defined as NULL and columns that have NOT NULLs, or, if using the Table Designer, you can check or uncheck the Allow Nulls option. These two different statements define whether data must be entered into the column or not. A NULL value means that there is absolutely nothing entered in that column—no data at all. A column with a NULL value is a special data state, with special meaning. This really means that the type of data within the column is unknown.

 By defining a column using the IDENTITY option, you are informing SQL Server that  The column will have a value generated by SQL Server.  There will be a start point (seed).  An increment value is given, informing SQL Server by how much each new ID should increase.  SQL server will manage the allocation of IDs.  From the Column Properties section for our column expand the Identity Specification node, as we need to set the Is Identity property to Yes. This will set the Identity Increment to 1 and the Identity Seed to 1 as well, as shown in Figure

 As a row is added to a table, rather than enforcing developers to add values to columns that could be populated by SQL Server, such as a column that details using a date and time when a row of data was added, it is possible to place a default value there instead. The default value can be any valid value for that data type.  From column properties insert your value in (Default value or binding).

 Once in the Table Designer, select the CustomerId column. This will be the column we are setting the primary key for. Right-click to bring up the pop-up menu shown in Figure

 To create the FOREIGN KEY constraint, right-click the upper pane in Table Designer and then click Relationships. When the Foreign Key Relationships dialog box appears, click Add to create the new constraint. Figure shows the dialog box with the initial foreign key, before any properties have been configured.

 At a minimum, we must modify the Tables And Columns Specification property group, which identifies the referenced and referencing columns in the foreign key. Select the property group listing and then click its associated browse button. When the Tables and Columns dialog box appears, select the Product table as the primary key table and the ProductID column from that table. For the SpecialtyProducts table, which is the foreign key table, select the ProductID column. In addition, modify the name of the foreign key, if desired. I went with fk_ProductID. The Tables and Columns dialog box should now look similar to the one shown in Figure

 You can create a UNIQUE constraint in the Indexes/Keys dialog box by, right-click the upper pane in Table Designer and then click indexes/keys then clicking the Add button.

 To add a check constraint, right-click the upper pane in Table Designer and then click Check Constraints. When the Check Constraints dialog box appears, click the Add button to create the new constraint. Figure 14 shows the dialog box with the initial constraint, before any properties have been configured.check constraint

 To create the CHECK constraint, you must configure the Expression property. You can either enter an expression directly or click the browse button to launch the Check Constraint Expression dialog box, where you have more room to work on your expression, as shown in Figure