SlideShare a Scribd company logo
1 of 72
SQL Server 2008 for Developers UTS Short Course
Peter Gfader Specializes in  C# and .NET (Java not anymore) TestingAutomated tests Agile, ScrumCertified Scrum Trainer Technology aficionado  Silverlight ASP.NET Windows Forms
Course Website http://sharepoint.ssw.com.au/Training/UTSSQL/Pages/ Course Timetable Course Materials
Course Overview
SQL Management Studio SQL Configuration Manager Consoles SQLCMD PowerShell SQL Profiler SQL Database Tuning Advisor Last Week
How to setup maintenance plans over night Database encryption Data Source code (Stored procs) Best practices Typical maintenance plans Policies Last Week - Additional
Modify maintenance plan 2nd page in wizard (new plan)
Encrypting data - Transparent Data Encryption (TDE) http://msdn.microsoft.com/en-us/library/bb934049.aspx http://www.acorns.com.au/blog/?p=147 Encrypting Connections to SQL Server http://msdn.microsoft.com/en-us/library/ms189067.aspx Encrypting source code http://www.codeproject.com/KB/database/ProtectSQLCodeObject.aspx Database encryption
http://ola.hallengren.com/ Steps Backup Integrity check  Index optimization Solution used in mission-critical environments in  many organizations. Best practices - Maintenance
Security Best Practices  http://download.microsoft.com/download/8/5/e/85eea4fa-b3bb-4426-97d0-7f7151b2011c/SQL2005SecBestPract.doc Security Best Practices Checklist http://technet.microsoft.com/en-us/library/cc966456.aspx   Best practices - Security
Create a schema called Salary Create a table called Employees in Schema Create a user called Manager Give only manager permission to update/insert/delete in schema Create a user called Peter Give Peter only read to schema (=salary) Create a user Alice Deny everything for Alice in Salary Homework?
Agenda New Data Types Inline variable assignment Table Value Parameters DDL Triggers CTE (Common Table Expressions) TOP %, XML Queries PIVOT/UNPIVOT ADO.NET
Datatypes - Exact Numerics bigint, int, smallint, tinyint -2^63 ... 2^63-1 0..255 Bit (0 or 1) decimal = numeric Exact type Numbers -10^38 +1 ...  10^38 – Money, smallmoney accuracy to a ten-thousandth money unit Smallmoney = smaller money
Datatypes – Approximate Numerics Floating point numeric data float real
Datatypes - text char Fixed length varchar Variable length
Datatypes - text char, varchar, text Ascii  - 1 byte nchar, nvarchar, ntext Unicode - 2 bytes binary, varbinary, image
Date and Time SQL 2008 now has the following data types to represent time: DateTime SmallDateTime Date Time DateTime2 – really a BigDateTime Min Date is 1st Jan 0000 Max date 31st Dec 9999 – Y10K BUG!! DateTimeOffset
Date Time details
Datatypes - Other cursor table Timestamp = rowversion binary number  Reflects data modifications uniqueidentifier = Guid Format: 04c4ce04-16c1-406f-a895-5dd321db7f0b
New Data Types Filestream Sparse Columns Filtered Indexes Spatial Data HierarchyID DATE and TIME data types
Example: Storing images I am designing an Employee table that needs to cater for employee photographs. What should I do?
blob vs. file system I am designing an Employee table that needs to cater for employee photographs. What should I do? You can store the image in the database (blob) You can store a URL to the image in the database (Recommended for SQL2005) http://www.ssw.com.au/ssw/standards/Rules/RulestoBetterSQLServerdatabases.aspx#ImageReplaceWithURL
blob ,[object Object],Database grows really big Backups take longer Your code needs to convert the bytes back into an image Your images are in sync with your data
File system ,[object Object],Database is smaller Easily validate or change the image (you can look at it on the file system) Data could become out of sync with the file system Need to backup the database and the file system
Filestream Filestream to the rescue Implemented as a special varbinary(max) where data is stored as a blob on the file system Allows you to have transactionally consistent Integrated backup and restore of your binary images Size limitation is the size of your hard drive’s free space
Problem Q:I’ve got an Contacts table with 200,000 rows. To support the latest Web 2.0 trends we want to also record the contact’s blog address. What should I do?
Solution? A:Just add a new BlogUrl column in
Solution? A:Just add a new BlogUrl column in Q:What’s the problem with that? A:Most of the entries in your table will be null, it wastes a lot of database space
Solution Use a sparse column These columns are new to SQL 2008 They are optimized for storing NULL values
Sparse Columns
Sparse Columns
Sparse Columns
Filtered Indexes Allows you to add an index to a column with a where clause Useful for indexing columns with null values in them
Spatial Data Types Geometry Geography Virtual Earth Integration Planar vs Geodetic Algorithms Separate install for spatial assemblies http://www.conceptdevelopment.net/Database/Geoquery/
Spatial Datatypes Hierarchy
Spatial Data Types Geometry allows you to represent and process polygons
How do I represent an Org Chart? Employee with a ManagerID column (self join) New HierarchyID data type Can be indexed using: Depth First  Breadth First
Depth First Search A depth-first index, rows in a subtree are stored near each other. For example, all employees that report through a manager are stored near their managers' record.
Breadth First Search A breadth-first stores the rows each level of the hierarchy together. For example, the records of employees who directly report to the same manager are stored near each other.
Inline Variable Assignment Instead of: DECLARE @myVar intSET @myVar = 5 You can: DECLARE @myVar int = 5
Table Value Parameters Pass in a table as an argument to a SPROC Instead of: exec sp_MySproc 'murphy,35;galen,31;samuels,27;colton,42‘	 SPROC needs to then parse that string
Table Value Parameters You can do this instead CREATE TYPE PeepsType AS TABLE (Name varchar(20), Age int) DECLARE @myPeeps PeepsType INSERT @myPeeps SELECT 'murphy', 35 INSERT @myPeeps SELECT 'galen', 31 INSERT @myPeeps SELECT 'samuels', 27 INSERT @myPeeps SELECT 'colton', 42exec sp_MySproc2 @myPeeps
Table Value Parameters The SPROC would look like this: CREATE PROCEDURE sp_MySproc2(@myPeeps PeepsType READONLY)
DDL Triggers Auditing, regulating schema changes, capture events on create_table, alter_procedure, drop_login etc
PIVOT
CTE (Common Table Expression) Before
CTE (Common Table Expressions) After
More features ROW NUMBER – see example TRY/Catch in queries – see example Top % WITH TIES select top with tie feature( if top 10 and there are 15 that match number 10 will bring back all 15)
Working with XML - RAW SELECT TOP 3 Person.FirstName, Person.LastName, PersonPhone.PhoneNumber FROM AdventureWorks.Person.Person 	INNER JOIN AdventureWorks.Person.PersonPhone ON PersonPhone.BusinessEntityID = Person.BusinessEntityID FOR XML RAW
Working with XML - RAW <row FirstName="Ken" LastName="Sánchez" PhoneNumber="697-555-0142"/> <row FirstName="Terri" LastName="Duffy" PhoneNumber="819-555-0175"/> <row FirstName="Roberto" LastName="Tamburello" PhoneNumber="212-555-0187"/>
Working with XML - RAW What happened to our relationships? RAW doesn’t show our table relationships but gives us a flat XML hierarchy
Working with XML - Auto SELECT TOP 3 Person.FirstName, Person.LastName, PersonPhone.PhoneNumber FROM AdventureWorks.Person.Person 	INNER JOIN AdventureWorks.Person.PersonPhone ON PersonPhone.BusinessEntityID = Person.BusinessEntityID FOR XML AUTO
Working with XML - Auto <AdventureWorks.Person.PersonFirstName="Ken" LastName="Sánchez"> <AdventureWorks.Person.PersonPhonePhoneNumber="697-555-0142"/> </AdventureWorks.Person.Person>
Working with XML - Auto Great, but what if I needed to format the XML to output into a certain schema
Working with XML - Explicit SELECT TOP 3  	1 AS TAG, 	NULL AS PARENT, BusinessEntityID AS [Person!1!BusinessEntityID], FirstName AS [Person!1!FirstName!ELEMENT] FROM AdventureWorks.Person.Person FOR XML EXPLICIT
Working with XML - Explicit <Person BusinessEntityID="285“> <FirstName>Syed</FirstName> </Person> <Person BusinessEntityID="293"> <FirstName>Catherine</FirstName> </Person> <Person BusinessEntityID="295"> <FirstName>Kim</FirstName> </Person>
Working with XML - Explicit Can control how the XML gets output Ugly query Is there a better way?
Working with XML - PATH SELECT TOP 3 BusinessEntityID "Person/@BusinessEntityID", FirstName "Person/FirstName" FROM AdventureWorks.Person.Person FOR XML PATH ('')
Working with XML - XQuery XQuery is a query language for XML Data
XQuery – Declaring our XML string DECLARE @x XML SET @x = '<christmaslist><person name = "betty" gift = "camera"/><person name = "zach" gift = "elmo doll"/><person name = "brad" gift = "socks"/></christmaslist>'
XQuery - Querying SELECT @x.exist('/christmaslist/person[@gift="socks"]') SELECT @x.exist('/christmaslist/person[@gift="lump of coal"]') SELECT @x.exist('/christmaslist/person[@gift="Socks"]‘) SELECT @x.value('/christmaslist[1]/person[1]/@name', 'VARCHAR(20)‘) SELECT @x.query('/christmaslist/person')
XQuery - Querying query() value() exist() nodes() modify()
XQuery - Resources http://msdn.microsoft.com/en-us/library/ms345117.aspx
ADO.NET ADO.NET gives you full control over how you access and retrieve data from the data source Strongly typed data sets Work in disconnected mode
ADO.NET SQLConnection Manages the connection to the database SQLCommand Defines the data to be read, updated etc. SQLDataAdapter Runs the SQLCommand against the database DataSet A complete in-memory copy of the data (tables, relationships, data types…) Search, filter, navigate your data – without even being connected to the database!
TSQL Tricks Randomize Select output Repeat statements with GO x
Resources 1/2 Spatial Data playground http://www.conceptdevelopment.net/Database/Geoquery/ Hidden Features in SQL Server http://stackoverflow.com/questions/121243/hidden-features-of-sql-server Top 10 Hidden Gems in SQL Server http://technet.microsoft.com/en-au/library/cc917696.aspx
What to do when you take over a new SQL Server box? http://www.brentozar.com/sql/blitz-minute-sql-server-takeovers/ Resources 2/2
Session 2 Lab  T-SQL Enhancements Download from Course Materials Site (to copy/paste scripts) or type manually http://sharepoint.ssw.com.au/training/UTSSQL/
Where Else Can I Get Help? Where else can I get help? Free chats and webcasts List of newsgroups Microsoft community sites Community events and columns www.microsoft.com/technet/community
3things… PeterGfader@ssw.com.au http://peitor.blogspot.com twitter.com/peitor
Thank You! Gateway Court Suite 10 81 - 91 Military Road Neutral Bay, Sydney NSW 2089 AUSTRALIA  ABN: 21 069 371 900  Phone: + 61 2 9953 3000 Fax: + 61 2 9953 3105  info@ssw.com.auwww.ssw.com.au

More Related Content

Viewers also liked

Better User Experience with .NET
Better User Experience with .NETBetter User Experience with .NET
Better User Experience with .NETPeter Gfader
 
ASP.NET 01 - Introduction
ASP.NET 01 - IntroductionASP.NET 01 - Introduction
ASP.NET 01 - IntroductionRandy Connolly
 
Work with data in ASP.NET
Work with data in ASP.NETWork with data in ASP.NET
Work with data in ASP.NETPeter Gfader
 
N-Tier Application with Windows Forms - Deployment and Security
N-Tier Application with Windows Forms - Deployment and SecurityN-Tier Application with Windows Forms - Deployment and Security
N-Tier Application with Windows Forms - Deployment and SecurityPeter Gfader
 
Web Service
Web ServiceWeb Service
Web ServiceKumar S
 
Structured Process Of Developing A Web Application
Structured Process Of Developing A Web ApplicationStructured Process Of Developing A Web Application
Structured Process Of Developing A Web ApplicationKumar S
 
Microsoft SQL Server 2012 Certifications and Training
Microsoft SQL Server 2012 Certifications and TrainingMicrosoft SQL Server 2012 Certifications and Training
Microsoft SQL Server 2012 Certifications and TrainingVishal Pawar
 
Introduction To SQL Server 2014
Introduction To SQL Server 2014Introduction To SQL Server 2014
Introduction To SQL Server 2014Vishal Pawar
 
MS SQLSERVER:Creating A Database
MS SQLSERVER:Creating A DatabaseMS SQLSERVER:Creating A Database
MS SQLSERVER:Creating A Databasesqlserver content
 
Tutorial sql server 2014 basic security priviledge, role, authentification
Tutorial sql server 2014 basic security  priviledge, role, authentificationTutorial sql server 2014 basic security  priviledge, role, authentification
Tutorial sql server 2014 basic security priviledge, role, authentificationJanuar Wicaksono
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive TechandMate
 
Oracle Forms Tutorial
Oracle Forms TutorialOracle Forms Tutorial
Oracle Forms TutorialATR Login
 

Viewers also liked (18)

Better User Experience with .NET
Better User Experience with .NETBetter User Experience with .NET
Better User Experience with .NET
 
ASP.NET 01 - Introduction
ASP.NET 01 - IntroductionASP.NET 01 - Introduction
ASP.NET 01 - Introduction
 
Work with data in ASP.NET
Work with data in ASP.NETWork with data in ASP.NET
Work with data in ASP.NET
 
Asp.net new
Asp.net newAsp.net new
Asp.net new
 
N-Tier Application with Windows Forms - Deployment and Security
N-Tier Application with Windows Forms - Deployment and SecurityN-Tier Application with Windows Forms - Deployment and Security
N-Tier Application with Windows Forms - Deployment and Security
 
Web Service
Web ServiceWeb Service
Web Service
 
Structured Process Of Developing A Web Application
Structured Process Of Developing A Web ApplicationStructured Process Of Developing A Web Application
Structured Process Of Developing A Web Application
 
Microsoft SQL Server 2012 Certifications and Training
Microsoft SQL Server 2012 Certifications and TrainingMicrosoft SQL Server 2012 Certifications and Training
Microsoft SQL Server 2012 Certifications and Training
 
Introduction To SQL Server 2014
Introduction To SQL Server 2014Introduction To SQL Server 2014
Introduction To SQL Server 2014
 
MS SQLSERVER:Creating A Database
MS SQLSERVER:Creating A DatabaseMS SQLSERVER:Creating A Database
MS SQLSERVER:Creating A Database
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
NETCONF YANG tutorial
NETCONF YANG tutorialNETCONF YANG tutorial
NETCONF YANG tutorial
 
Tutorial sql server 2014 basic security priviledge, role, authentification
Tutorial sql server 2014 basic security  priviledge, role, authentificationTutorial sql server 2014 basic security  priviledge, role, authentification
Tutorial sql server 2014 basic security priviledge, role, authentification
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
 
Oracle Forms Tutorial
Oracle Forms TutorialOracle Forms Tutorial
Oracle Forms Tutorial
 

Similar to SQL Server - Introduction to TSQL

Oracle to Amazon Aurora Migration, Step by Step - AWS Online Tech Talks
Oracle to Amazon Aurora Migration, Step by Step - AWS Online Tech TalksOracle to Amazon Aurora Migration, Step by Step - AWS Online Tech Talks
Oracle to Amazon Aurora Migration, Step by Step - AWS Online Tech TalksAmazon Web Services
 
Tech Days09 Sqldev
Tech Days09 SqldevTech Days09 Sqldev
Tech Days09 Sqldevllangit
 
SQL Server 2008 for Developers
SQL Server 2008 for DevelopersSQL Server 2008 for Developers
SQL Server 2008 for Developersllangit
 
SQL Server 2008 for .NET Developers
SQL Server 2008 for .NET DevelopersSQL Server 2008 for .NET Developers
SQL Server 2008 for .NET Developersllangit
 
TSQL in SQL Server 2012
TSQL in SQL Server 2012TSQL in SQL Server 2012
TSQL in SQL Server 2012Eduardo Castro
 
Introduction to sql server
Introduction to sql serverIntroduction to sql server
Introduction to sql serverVinay Thota
 
Asp.net interview questions
Asp.net interview questionsAsp.net interview questions
Asp.net interview questionsAkhil Mittal
 
SQL Server - High availability
SQL Server - High availabilitySQL Server - High availability
SQL Server - High availabilityPeter Gfader
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresSteven Johnson
 
What is struts_en
What is struts_enWhat is struts_en
What is struts_entechbed
 
Windows Azure and a little SQL Data Services
Windows Azure and a little SQL Data ServicesWindows Azure and a little SQL Data Services
Windows Azure and a little SQL Data Servicesukdpe
 
Be a database professional
Be a database professionalBe a database professional
Be a database professionalSayed Ahmed
 
Be a database professional
Be a database professionalBe a database professional
Be a database professionalSayed Ahmed
 
Data modeling star schema
Data modeling star schemaData modeling star schema
Data modeling star schemaSayed Ahmed
 
MySQL Scaling Presentation
MySQL Scaling PresentationMySQL Scaling Presentation
MySQL Scaling PresentationTommy Falgout
 
Intro to Talend Open Studio for Data Integration
Intro to Talend Open Studio for Data IntegrationIntro to Talend Open Studio for Data Integration
Intro to Talend Open Studio for Data IntegrationPhilip Yurchuk
 
PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#Michael Heron
 
SQL Server 2008 Integration Services
SQL Server 2008 Integration ServicesSQL Server 2008 Integration Services
SQL Server 2008 Integration ServicesEduardo Castro
 

Similar to SQL Server - Introduction to TSQL (20)

DP-900.pdf
DP-900.pdfDP-900.pdf
DP-900.pdf
 
Oracle to Amazon Aurora Migration, Step by Step - AWS Online Tech Talks
Oracle to Amazon Aurora Migration, Step by Step - AWS Online Tech TalksOracle to Amazon Aurora Migration, Step by Step - AWS Online Tech Talks
Oracle to Amazon Aurora Migration, Step by Step - AWS Online Tech Talks
 
Tech Days09 Sqldev
Tech Days09 SqldevTech Days09 Sqldev
Tech Days09 Sqldev
 
SQL Server 2008 for Developers
SQL Server 2008 for DevelopersSQL Server 2008 for Developers
SQL Server 2008 for Developers
 
SQL Server 2008 for .NET Developers
SQL Server 2008 for .NET DevelopersSQL Server 2008 for .NET Developers
SQL Server 2008 for .NET Developers
 
TSQL in SQL Server 2012
TSQL in SQL Server 2012TSQL in SQL Server 2012
TSQL in SQL Server 2012
 
Introduction to sql server
Introduction to sql serverIntroduction to sql server
Introduction to sql server
 
Module02
Module02Module02
Module02
 
Asp.net interview questions
Asp.net interview questionsAsp.net interview questions
Asp.net interview questions
 
SQL Server - High availability
SQL Server - High availabilitySQL Server - High availability
SQL Server - High availability
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome Measures
 
What is struts_en
What is struts_enWhat is struts_en
What is struts_en
 
Windows Azure and a little SQL Data Services
Windows Azure and a little SQL Data ServicesWindows Azure and a little SQL Data Services
Windows Azure and a little SQL Data Services
 
Be a database professional
Be a database professionalBe a database professional
Be a database professional
 
Be a database professional
Be a database professionalBe a database professional
Be a database professional
 
Data modeling star schema
Data modeling star schemaData modeling star schema
Data modeling star schema
 
MySQL Scaling Presentation
MySQL Scaling PresentationMySQL Scaling Presentation
MySQL Scaling Presentation
 
Intro to Talend Open Studio for Data Integration
Intro to Talend Open Studio for Data IntegrationIntro to Talend Open Studio for Data Integration
Intro to Talend Open Studio for Data Integration
 
PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#
 
SQL Server 2008 Integration Services
SQL Server 2008 Integration ServicesSQL Server 2008 Integration Services
SQL Server 2008 Integration Services
 

More from Peter Gfader

Achieving Technical Excellence in Your Software Teams - from Devternity
Achieving Technical Excellence in Your Software Teams - from Devternity Achieving Technical Excellence in Your Software Teams - from Devternity
Achieving Technical Excellence in Your Software Teams - from Devternity Peter Gfader
 
You Can't Be Agile If Your Testing Practices Suck - Vilnius October 2019
You Can't Be Agile If Your Testing Practices Suck - Vilnius October 2019You Can't Be Agile If Your Testing Practices Suck - Vilnius October 2019
You Can't Be Agile If Your Testing Practices Suck - Vilnius October 2019Peter Gfader
 
You Cant Be Agile If Your Code Sucks (with 9 Tips For Dev Teams)
You Cant Be Agile If Your Code Sucks (with 9 Tips For Dev Teams)You Cant Be Agile If Your Code Sucks (with 9 Tips For Dev Teams)
You Cant Be Agile If Your Code Sucks (with 9 Tips For Dev Teams)Peter Gfader
 
How to make more impact as an engineer
How to make more impact as an engineerHow to make more impact as an engineer
How to make more impact as an engineerPeter Gfader
 
13 explosive things you should try as an agilist
13 explosive things you should try as an agilist13 explosive things you should try as an agilist
13 explosive things you should try as an agilistPeter Gfader
 
You cant be agile if your code sucks
You cant be agile if your code sucksYou cant be agile if your code sucks
You cant be agile if your code sucksPeter Gfader
 
Use Scrum and Continuous Delivery to innovate like crazy!
Use Scrum and Continuous Delivery to innovate like crazy!Use Scrum and Continuous Delivery to innovate like crazy!
Use Scrum and Continuous Delivery to innovate like crazy!Peter Gfader
 
Innovation durch Scrum und Continuous Delivery
Innovation durch Scrum und Continuous DeliveryInnovation durch Scrum und Continuous Delivery
Innovation durch Scrum und Continuous DeliveryPeter Gfader
 
Qcon london2012 recap
Qcon london2012 recapQcon london2012 recap
Qcon london2012 recapPeter Gfader
 
Continuous Delivery with TFS msbuild msdeploy
Continuous Delivery with TFS msbuild msdeployContinuous Delivery with TFS msbuild msdeploy
Continuous Delivery with TFS msbuild msdeployPeter Gfader
 
Silverlight vs HTML5 - Lessons learned from the real world...
Silverlight vs HTML5 - Lessons learned from the real world...Silverlight vs HTML5 - Lessons learned from the real world...
Silverlight vs HTML5 - Lessons learned from the real world...Peter Gfader
 
Clean Code Development
Clean Code DevelopmentClean Code Development
Clean Code DevelopmentPeter Gfader
 
Data Mining with SQL Server 2008
Data Mining with SQL Server 2008Data Mining with SQL Server 2008
Data Mining with SQL Server 2008Peter Gfader
 
SSAS - Other Cube Browsers
SSAS - Other Cube BrowsersSSAS - Other Cube Browsers
SSAS - Other Cube BrowsersPeter Gfader
 
Reports with SQL Server Reporting Services
Reports with SQL Server Reporting ServicesReports with SQL Server Reporting Services
Reports with SQL Server Reporting ServicesPeter Gfader
 
OLAP – Creating Cubes with SQL Server Analysis Services
OLAP – Creating Cubes with SQL Server Analysis ServicesOLAP – Creating Cubes with SQL Server Analysis Services
OLAP – Creating Cubes with SQL Server Analysis ServicesPeter Gfader
 
Business Intelligence with SQL Server
Business Intelligence with SQL ServerBusiness Intelligence with SQL Server
Business Intelligence with SQL ServerPeter Gfader
 
SQL Server - Full text search
SQL Server - Full text searchSQL Server - Full text search
SQL Server - Full text searchPeter Gfader
 
Usability AJAX and other ASP.NET Features
Usability AJAX and other ASP.NET FeaturesUsability AJAX and other ASP.NET Features
Usability AJAX and other ASP.NET FeaturesPeter Gfader
 

More from Peter Gfader (20)

Achieving Technical Excellence in Your Software Teams - from Devternity
Achieving Technical Excellence in Your Software Teams - from Devternity Achieving Technical Excellence in Your Software Teams - from Devternity
Achieving Technical Excellence in Your Software Teams - from Devternity
 
You Can't Be Agile If Your Testing Practices Suck - Vilnius October 2019
You Can't Be Agile If Your Testing Practices Suck - Vilnius October 2019You Can't Be Agile If Your Testing Practices Suck - Vilnius October 2019
You Can't Be Agile If Your Testing Practices Suck - Vilnius October 2019
 
You Cant Be Agile If Your Code Sucks (with 9 Tips For Dev Teams)
You Cant Be Agile If Your Code Sucks (with 9 Tips For Dev Teams)You Cant Be Agile If Your Code Sucks (with 9 Tips For Dev Teams)
You Cant Be Agile If Your Code Sucks (with 9 Tips For Dev Teams)
 
How to make more impact as an engineer
How to make more impact as an engineerHow to make more impact as an engineer
How to make more impact as an engineer
 
13 explosive things you should try as an agilist
13 explosive things you should try as an agilist13 explosive things you should try as an agilist
13 explosive things you should try as an agilist
 
You cant be agile if your code sucks
You cant be agile if your code sucksYou cant be agile if your code sucks
You cant be agile if your code sucks
 
Use Scrum and Continuous Delivery to innovate like crazy!
Use Scrum and Continuous Delivery to innovate like crazy!Use Scrum and Continuous Delivery to innovate like crazy!
Use Scrum and Continuous Delivery to innovate like crazy!
 
Innovation durch Scrum und Continuous Delivery
Innovation durch Scrum und Continuous DeliveryInnovation durch Scrum und Continuous Delivery
Innovation durch Scrum und Continuous Delivery
 
Speed = $$$
Speed = $$$Speed = $$$
Speed = $$$
 
Qcon london2012 recap
Qcon london2012 recapQcon london2012 recap
Qcon london2012 recap
 
Continuous Delivery with TFS msbuild msdeploy
Continuous Delivery with TFS msbuild msdeployContinuous Delivery with TFS msbuild msdeploy
Continuous Delivery with TFS msbuild msdeploy
 
Silverlight vs HTML5 - Lessons learned from the real world...
Silverlight vs HTML5 - Lessons learned from the real world...Silverlight vs HTML5 - Lessons learned from the real world...
Silverlight vs HTML5 - Lessons learned from the real world...
 
Clean Code Development
Clean Code DevelopmentClean Code Development
Clean Code Development
 
Data Mining with SQL Server 2008
Data Mining with SQL Server 2008Data Mining with SQL Server 2008
Data Mining with SQL Server 2008
 
SSAS - Other Cube Browsers
SSAS - Other Cube BrowsersSSAS - Other Cube Browsers
SSAS - Other Cube Browsers
 
Reports with SQL Server Reporting Services
Reports with SQL Server Reporting ServicesReports with SQL Server Reporting Services
Reports with SQL Server Reporting Services
 
OLAP – Creating Cubes with SQL Server Analysis Services
OLAP – Creating Cubes with SQL Server Analysis ServicesOLAP – Creating Cubes with SQL Server Analysis Services
OLAP – Creating Cubes with SQL Server Analysis Services
 
Business Intelligence with SQL Server
Business Intelligence with SQL ServerBusiness Intelligence with SQL Server
Business Intelligence with SQL Server
 
SQL Server - Full text search
SQL Server - Full text searchSQL Server - Full text search
SQL Server - Full text search
 
Usability AJAX and other ASP.NET Features
Usability AJAX and other ASP.NET FeaturesUsability AJAX and other ASP.NET Features
Usability AJAX and other ASP.NET Features
 

Recently uploaded

KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Recently uploaded (20)

KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 

SQL Server - Introduction to TSQL

  • 1. SQL Server 2008 for Developers UTS Short Course
  • 2. Peter Gfader Specializes in C# and .NET (Java not anymore) TestingAutomated tests Agile, ScrumCertified Scrum Trainer Technology aficionado Silverlight ASP.NET Windows Forms
  • 5. SQL Management Studio SQL Configuration Manager Consoles SQLCMD PowerShell SQL Profiler SQL Database Tuning Advisor Last Week
  • 6. How to setup maintenance plans over night Database encryption Data Source code (Stored procs) Best practices Typical maintenance plans Policies Last Week - Additional
  • 7. Modify maintenance plan 2nd page in wizard (new plan)
  • 8. Encrypting data - Transparent Data Encryption (TDE) http://msdn.microsoft.com/en-us/library/bb934049.aspx http://www.acorns.com.au/blog/?p=147 Encrypting Connections to SQL Server http://msdn.microsoft.com/en-us/library/ms189067.aspx Encrypting source code http://www.codeproject.com/KB/database/ProtectSQLCodeObject.aspx Database encryption
  • 9. http://ola.hallengren.com/ Steps Backup Integrity check Index optimization Solution used in mission-critical environments in many organizations. Best practices - Maintenance
  • 10. Security Best Practices http://download.microsoft.com/download/8/5/e/85eea4fa-b3bb-4426-97d0-7f7151b2011c/SQL2005SecBestPract.doc Security Best Practices Checklist http://technet.microsoft.com/en-us/library/cc966456.aspx   Best practices - Security
  • 11. Create a schema called Salary Create a table called Employees in Schema Create a user called Manager Give only manager permission to update/insert/delete in schema Create a user called Peter Give Peter only read to schema (=salary) Create a user Alice Deny everything for Alice in Salary Homework?
  • 12. Agenda New Data Types Inline variable assignment Table Value Parameters DDL Triggers CTE (Common Table Expressions) TOP %, XML Queries PIVOT/UNPIVOT ADO.NET
  • 13. Datatypes - Exact Numerics bigint, int, smallint, tinyint -2^63 ... 2^63-1 0..255 Bit (0 or 1) decimal = numeric Exact type Numbers -10^38 +1 ... 10^38 – Money, smallmoney accuracy to a ten-thousandth money unit Smallmoney = smaller money
  • 14. Datatypes – Approximate Numerics Floating point numeric data float real
  • 15. Datatypes - text char Fixed length varchar Variable length
  • 16. Datatypes - text char, varchar, text Ascii - 1 byte nchar, nvarchar, ntext Unicode - 2 bytes binary, varbinary, image
  • 17. Date and Time SQL 2008 now has the following data types to represent time: DateTime SmallDateTime Date Time DateTime2 – really a BigDateTime Min Date is 1st Jan 0000 Max date 31st Dec 9999 – Y10K BUG!! DateTimeOffset
  • 19. Datatypes - Other cursor table Timestamp = rowversion binary number Reflects data modifications uniqueidentifier = Guid Format: 04c4ce04-16c1-406f-a895-5dd321db7f0b
  • 20. New Data Types Filestream Sparse Columns Filtered Indexes Spatial Data HierarchyID DATE and TIME data types
  • 21. Example: Storing images I am designing an Employee table that needs to cater for employee photographs. What should I do?
  • 22. blob vs. file system I am designing an Employee table that needs to cater for employee photographs. What should I do? You can store the image in the database (blob) You can store a URL to the image in the database (Recommended for SQL2005) http://www.ssw.com.au/ssw/standards/Rules/RulestoBetterSQLServerdatabases.aspx#ImageReplaceWithURL
  • 23.
  • 24.
  • 25. Filestream Filestream to the rescue Implemented as a special varbinary(max) where data is stored as a blob on the file system Allows you to have transactionally consistent Integrated backup and restore of your binary images Size limitation is the size of your hard drive’s free space
  • 26. Problem Q:I’ve got an Contacts table with 200,000 rows. To support the latest Web 2.0 trends we want to also record the contact’s blog address. What should I do?
  • 27. Solution? A:Just add a new BlogUrl column in
  • 28. Solution? A:Just add a new BlogUrl column in Q:What’s the problem with that? A:Most of the entries in your table will be null, it wastes a lot of database space
  • 29. Solution Use a sparse column These columns are new to SQL 2008 They are optimized for storing NULL values
  • 33. Filtered Indexes Allows you to add an index to a column with a where clause Useful for indexing columns with null values in them
  • 34. Spatial Data Types Geometry Geography Virtual Earth Integration Planar vs Geodetic Algorithms Separate install for spatial assemblies http://www.conceptdevelopment.net/Database/Geoquery/
  • 36. Spatial Data Types Geometry allows you to represent and process polygons
  • 37. How do I represent an Org Chart? Employee with a ManagerID column (self join) New HierarchyID data type Can be indexed using: Depth First Breadth First
  • 38. Depth First Search A depth-first index, rows in a subtree are stored near each other. For example, all employees that report through a manager are stored near their managers' record.
  • 39. Breadth First Search A breadth-first stores the rows each level of the hierarchy together. For example, the records of employees who directly report to the same manager are stored near each other.
  • 40. Inline Variable Assignment Instead of: DECLARE @myVar intSET @myVar = 5 You can: DECLARE @myVar int = 5
  • 41. Table Value Parameters Pass in a table as an argument to a SPROC Instead of: exec sp_MySproc 'murphy,35;galen,31;samuels,27;colton,42‘ SPROC needs to then parse that string
  • 42. Table Value Parameters You can do this instead CREATE TYPE PeepsType AS TABLE (Name varchar(20), Age int) DECLARE @myPeeps PeepsType INSERT @myPeeps SELECT 'murphy', 35 INSERT @myPeeps SELECT 'galen', 31 INSERT @myPeeps SELECT 'samuels', 27 INSERT @myPeeps SELECT 'colton', 42exec sp_MySproc2 @myPeeps
  • 43. Table Value Parameters The SPROC would look like this: CREATE PROCEDURE sp_MySproc2(@myPeeps PeepsType READONLY)
  • 44. DDL Triggers Auditing, regulating schema changes, capture events on create_table, alter_procedure, drop_login etc
  • 45. PIVOT
  • 46. CTE (Common Table Expression) Before
  • 47. CTE (Common Table Expressions) After
  • 48. More features ROW NUMBER – see example TRY/Catch in queries – see example Top % WITH TIES select top with tie feature( if top 10 and there are 15 that match number 10 will bring back all 15)
  • 49. Working with XML - RAW SELECT TOP 3 Person.FirstName, Person.LastName, PersonPhone.PhoneNumber FROM AdventureWorks.Person.Person INNER JOIN AdventureWorks.Person.PersonPhone ON PersonPhone.BusinessEntityID = Person.BusinessEntityID FOR XML RAW
  • 50. Working with XML - RAW <row FirstName="Ken" LastName="Sánchez" PhoneNumber="697-555-0142"/> <row FirstName="Terri" LastName="Duffy" PhoneNumber="819-555-0175"/> <row FirstName="Roberto" LastName="Tamburello" PhoneNumber="212-555-0187"/>
  • 51. Working with XML - RAW What happened to our relationships? RAW doesn’t show our table relationships but gives us a flat XML hierarchy
  • 52. Working with XML - Auto SELECT TOP 3 Person.FirstName, Person.LastName, PersonPhone.PhoneNumber FROM AdventureWorks.Person.Person INNER JOIN AdventureWorks.Person.PersonPhone ON PersonPhone.BusinessEntityID = Person.BusinessEntityID FOR XML AUTO
  • 53. Working with XML - Auto <AdventureWorks.Person.PersonFirstName="Ken" LastName="Sánchez"> <AdventureWorks.Person.PersonPhonePhoneNumber="697-555-0142"/> </AdventureWorks.Person.Person>
  • 54. Working with XML - Auto Great, but what if I needed to format the XML to output into a certain schema
  • 55. Working with XML - Explicit SELECT TOP 3 1 AS TAG, NULL AS PARENT, BusinessEntityID AS [Person!1!BusinessEntityID], FirstName AS [Person!1!FirstName!ELEMENT] FROM AdventureWorks.Person.Person FOR XML EXPLICIT
  • 56. Working with XML - Explicit <Person BusinessEntityID="285“> <FirstName>Syed</FirstName> </Person> <Person BusinessEntityID="293"> <FirstName>Catherine</FirstName> </Person> <Person BusinessEntityID="295"> <FirstName>Kim</FirstName> </Person>
  • 57. Working with XML - Explicit Can control how the XML gets output Ugly query Is there a better way?
  • 58. Working with XML - PATH SELECT TOP 3 BusinessEntityID "Person/@BusinessEntityID", FirstName "Person/FirstName" FROM AdventureWorks.Person.Person FOR XML PATH ('')
  • 59. Working with XML - XQuery XQuery is a query language for XML Data
  • 60. XQuery – Declaring our XML string DECLARE @x XML SET @x = '<christmaslist><person name = "betty" gift = "camera"/><person name = "zach" gift = "elmo doll"/><person name = "brad" gift = "socks"/></christmaslist>'
  • 61. XQuery - Querying SELECT @x.exist('/christmaslist/person[@gift="socks"]') SELECT @x.exist('/christmaslist/person[@gift="lump of coal"]') SELECT @x.exist('/christmaslist/person[@gift="Socks"]‘) SELECT @x.value('/christmaslist[1]/person[1]/@name', 'VARCHAR(20)‘) SELECT @x.query('/christmaslist/person')
  • 62. XQuery - Querying query() value() exist() nodes() modify()
  • 63. XQuery - Resources http://msdn.microsoft.com/en-us/library/ms345117.aspx
  • 64. ADO.NET ADO.NET gives you full control over how you access and retrieve data from the data source Strongly typed data sets Work in disconnected mode
  • 65. ADO.NET SQLConnection Manages the connection to the database SQLCommand Defines the data to be read, updated etc. SQLDataAdapter Runs the SQLCommand against the database DataSet A complete in-memory copy of the data (tables, relationships, data types…) Search, filter, navigate your data – without even being connected to the database!
  • 66. TSQL Tricks Randomize Select output Repeat statements with GO x
  • 67. Resources 1/2 Spatial Data playground http://www.conceptdevelopment.net/Database/Geoquery/ Hidden Features in SQL Server http://stackoverflow.com/questions/121243/hidden-features-of-sql-server Top 10 Hidden Gems in SQL Server http://technet.microsoft.com/en-au/library/cc917696.aspx
  • 68. What to do when you take over a new SQL Server box? http://www.brentozar.com/sql/blitz-minute-sql-server-takeovers/ Resources 2/2
  • 69. Session 2 Lab T-SQL Enhancements Download from Course Materials Site (to copy/paste scripts) or type manually http://sharepoint.ssw.com.au/training/UTSSQL/
  • 70. Where Else Can I Get Help? Where else can I get help? Free chats and webcasts List of newsgroups Microsoft community sites Community events and columns www.microsoft.com/technet/community
  • 72. Thank You! Gateway Court Suite 10 81 - 91 Military Road Neutral Bay, Sydney NSW 2089 AUSTRALIA ABN: 21 069 371 900 Phone: + 61 2 9953 3000 Fax: + 61 2 9953 3105 info@ssw.com.auwww.ssw.com.au

Editor's Notes

  1. Java current version 1.6 Update 171.7 released next year 2010Dynamic languages Parallel computingMaybe closures
  2. TEST that I will do:1. Create a new table called Bonus in schema Salary2. Login as Alice and try to access Bonus (with all permissions on Bonus)--&gt; Should not be able to
  3. decimalFixed precision and scale numeric data from -10^38 +1 through 10^38 –1. numericFunctionally equivalent to decimal.moneyMonetary data values from -2^63 (-922,337,203,685,477.5808) through 2^63 - 1 (+922,337,203,685,477.5807), with accuracy to a ten-thousandth of a monetary unit.smallmoneyMonetary data values from -214,748.3648 through +214,748.3647, with accuracy to a ten-thousandth of a monetary unit.
  4. Date = 3 bytes only DateDate– Enthält nur den Datumswert– Feste Größe von 3 byte– Spanne: 01.01.0001 – 31.12.9999– Bsp: 13-11-2008 oder 2008-11-13Time(n)– Enthält nur den Zeitwert– Variable Größe von 3-5 byte–Genauigkeit bis zu 100 Nanosekunden möglich– Bsp: 08:15:30.11223DateTimeOffset(n)– Enthält Datum und Uhrzeit inklusive der Zeitzonenverschiebung– Variable Größe von 8-10 byte–Genauigkeit bis zu 100 Nanosekunden möglich– Bsp: 2008-11-13 08:15:30.11223 01:00DateTime2(n)– Kombination aus Date und Time Datentyp– Variable Größe von 6-8 byte–Genauigkeit bis zu 100 Nanosekunden möglich– Spanne: 01.01.0001 – 31.12.9999– Bsp: 13-11-2008 08:15:30.11223
  5. Needs NTFSTransaction saveNo datasize limitBackup works
  6. USE AdventureWorksGO CREATE TABLE DocumentStore(DocIDint PRIMARY KEY, Title varchar(200) NOT NULL,ProductionSpecificationvarchar(20) SPARSE NULL,ProductionLocationsmallintSPARSE NULL,MarketingSurveyGroupvarchar(20) SPARSE NULL ) ;GO
  7. Sparse columns require more storage space for nonnull values than the space required for identical data that is not marked SPARSE. The following tables show the space usage for each data type. The NULL Percentage column indicates what percent of the data must be NULL for a net space savings of 40 percent.
  8. Clustered Index – Index that configures internal sorting of table(Can be only one on table)
  9. Points LinesPolygonsMultipoints
  10. http://www.conceptdevelopment.net/Database/Geoquery/
  11. http://technet.microsoft.com/en-us/magazine/cc434692(TechNet.10).aspxhttp://msdn.microsoft.com/en-us/library/bb630263.aspxSELECT OrgNode.ToString() AS LogicalNode, * FROM NewOrgORDER BY LogicalNode;GO
  12. A Common Table Expression (CTE) is a temporary result set derived from a simple query. A CTE can be used in many of the same ways you use a derived table. CTEs can also contain references to themselves. This allows database developers to write recursive queries. CTEs can also be used in place of views.
  13. XML Output – see exampleselect TOP 10 WITH TIES * from AdventureWorks.Person.ContactORDER BY Titleselect ROW_NUMBER() over(order by FirstName), *from AdventureWorksLT.SalesLT.Customerorder by FirstName
  14. * The query() method is useful for extracting parts of an XML instance. The XQuery expression evaluates to a list of XML nodes. The subtree rooted at each of these nodes is returned in document order. The result type is untyped XML. * The value() method extracts a scalar value from an XML instance. It returns the value of the node the XQuery expression evaluates to. This value is converted to a Transact-SQL type specified as the second argument of the value() method. * The exist() method is useful for existential checks on an XML instance. It returns 1 if the XQuery expression evaluates to non-null node list; otherwise it returns 0. * The nodes() method yields instances of a special XML data type, each of which has its context set to a different node that the XQuery expression evaluates to. The special XML data type supports the query(), value(), nodes(), and exist() methods, and can be used in count(*) aggregations and NULL checks. All other uses result in an error. * The modify() method permits modifying parts of an XML instance, such as adding or deleting subtrees, or replacing scalar values such as the price of a book from 9.99 to a 39.99.
  15. -- Return rows in a random orderSELECT     SomeColumnFROM     SomeTableORDER BY     NEWID()-- repeat 10 timesPRINT &apos;X&apos;GO 10