What is your Character Data Type? March 5, 2016 John Deardurff Website:

Slides:



Advertisements
Similar presentations
Project Management Database and SQL Server Katmai New Features Qingsong Yao
Advertisements

Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
Copyright ©2014 Pearson Education, Inc. Chapter 6 Physical Design Chapter6.1.
Database Fundamentals
Copyright © Curt Hill SQL The Data Definition Language.
Working with Data Types February 7, 2015 John Deardurff Website:
Module 2 Working with Data Types. Module Overview Using Data Types Working with Character Data Converting Data Types Working with Specialized Data Types.
Overview of SQL Server Alka Arora.
Module 4: Data Objects. Overview Tables are the main objects that store data Indexes, views, stored programs and other objects are the support structures.
Irwin/McGraw-Hill Copyright © 2000 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS5th Edition.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Chapter 7 SQL HUANG XUEHUA. SQL SQL server2005 introduction Install components  management studio.
Architecture Rajesh. Components of Database Engine.
Using New Data Types in 2008 Andrew Couch UK Access User Group ASC associates
WHAT’S NEW IN SQL SERVER 2008: T-SQL Martin Bell SQL Server MVP.
1 All Powder Board and Ski SQL Server Workbook Chapter 2: Database Design Jerry Post Copyright © 2004.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
Unit 6 Data Storage Design. Key Concepts 1. Database overview 2. SQL review 3. Designing fields 4. Denormalization 5. File organization 6. Object-relational.
11 3 / 12 CHAPTER Databases MIS105 Lec15 Irfan Ahmed Ilyas.
MySQL More… 1. More on SQL In MySQL, the Information Schema is the “Catalog” in the SQL standard SQL has three components: Data definition Data manipulation.
Data Types Lesson 4. Skills Matrix Table A table stores your data. Tables are relational in that they are organized as rows and columns (a matrix). Each.
SQL Server 2005 Implementation and Maintenance Chapter 3: Tables and Views.
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.
SQL for SQL Server, C13© 2002, Mike Murach & Associates, Inc. Slide 1.
03 | SQL Server Data Types Brian Alderman | MCT, CEO / Founder of MicroTechPoint Tobias Ternstrom | Microsoft SQL Server Program Manager.
Data types  CHAR (size): This data type is used to store character strings values of fixed length. The size in brackets determines the number of characters.
Sql DDL queries CS 260 Database Systems.
IMS 4212: Data Modeling—Attributes and Domains 1 Dr. Lawrence West, Management Dept., University of Central Florida Attributes and Domains.
Best Practices in SQL Programming. Do not use irrelevant datatype  VARCHAR instead of DATETIME  CHAR(N) instead of VARCHAR(N)  etc.
INTRODUCING SQL SERVER 2012 COLUMNSTORE INDEXES Exploring and Managing SQL Server 2012 Database Engine Improvements.
Academic Year 2015 Autumn. MODULE CC2006NI: Data Modelling and Database Systems Academic Year 2015 Autumn.
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.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Module 9: Using Advanced Techniques. Considerations for Querying Data Working with Data Types Cursors and Set-Based Queries Dynamic SQL Maintaining Query.
Creating E/R Diagrams with SQL Server Management Studio, Writing SQL Queries D0ncho Minkov Telerik School Academy schoolacademy.telerik.com Technical Trainer.
14 New T-SQL Functions By Sam Nasr, MCAD, MCT, MCTS NIS August 18, 2012.
14 New T-SQL Functions By Sam Nasr, MCAD, MCT, MCTS NIS
Querying with Transact-SQL
Creating Database Objects
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Data Definition and Data Types
The Basics of Data Manipulation
Module 2: Creating Data Types and Tables
Lecture 6 Data Model Design (continued)
Lesson 7 Managing Data Creating a database with Web Matrix.
Attributes and Domains
Ouch! Our Data Type Choices Did THAT?
SQL Server 2016 JSON Support FOR Data Warehousing
SQL Implementation & Administration
Working with SQL Server 2016 Data Types
What is Database Administration
14 T-SQL Functions You May Not Know
Migrating a Disk-based Table to a Memory-optimized one in SQL Server
Proper DataType Usage = Guaranteed Better Performance and Accuracy
What is your Character Data Type?
Working with Data Types
The Basics of Data Manipulation
Database systems Lecture 2 – Data Types
CIS 136 Building Mobile Apps
A JSON’s Journey through SQL Server
PT2520 Unit 5: Physical Design
Data Types Do Matter Start local instance of SQL Start ZoomIt
14 T-SQL Functions You May Not Know
Attributes and Domains
Creating Database Objects
Introduction to SQL Server and the Structure Query Language
Working with SQL Server 2016 Data Types
Presentation transcript:

What is your Character Data Type? March 5, 2016 John Deardurff Website:

We will learn about the basic SQL Server Data Types Used for Columns, Variables, Expressions, & Parameters Fundamental to writing queries in T-SQL Fundamental to designing tables. Choosing the right data type ensures data integrity and accuracy by creating a constraint on data input Choosing the right data type can save hard drive space, space in memory, and bandwidth on your network

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

Data types determine what kind of data can be held: Integers, characters, dates, money, decimals, etc.

A Byte saved is a Byte earned. ~ Benjamin Franklin The problem with quotes from the internet is it is hard to verify their authenticity. ~ Abraham Lincoln

1 byte per char 2 bytes per char

Free Space Header contains Page Information such a Page Number and Page Type Data Rows or Free Space Displays how far from beginning of page each row is located.

IN_ROW_DATA – Fixed length data must be stored here. – Rows cannot extend beyond pages – Data Page is 8060 bytes ROW_OVERFLOW_DATA – varchar(8000) / nvarchar(8000) / varbinary(8000) – When a column can’t fit onto a page – No control over which column overflows LOB_DATA (For out of row storage) – varchar(max) / nvarchar(max) / varbinary(max) – 16 byte pointer to out of row tree.

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

DATETIME, SMALLDATETIME, DATETIME2, and DATETIMEOFFSET include both date and time data If only date is specified, time set to midnight (all zeroes) If only time is specified, date set to base date (January 1, 1900) DATETIME = ' '; DATETIME = ' '; RESULT :00: RESULT :00:00.000

CHAR -> VARCHAR -> NCHAR -> NVARCHAR -> BIT -> TINYINT -> SMALLINT -> INT -> BIGINT -> MONEY -> DECIMAL -> TIME -> DATE -> DATETIME2 -> XML Data type precedence determines which data type will be chosen when expressions of different types are combined Data type with the lower precedence is implicitly converted to the data type with the higher precedence Conversion to type of lower precedence must be made explicitly (with CAST or CONVERT function)