ITCamp 2012 - Cristi Lefter - SQL Server 2012 for developers

  • 500 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
500
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
19
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. SQL Server 2012 for developers Cristian Lefter, SQL Server MVP http://about.me/CristianLefter@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 2. ITCamp 2012 sponsors Mobile & Development@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 3. Agenda Mobile & Development• Columnstore indexes• Business Intelligence Development Studio• SQL Server Express LocalDB• Transact-SQL improvements• Extended Events enhancements• SQL Server 2012 certification• Next steps@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 4. COLUMNSTORE INDEXES@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 5. Columnstore indexes Mobile & Development Row Store (Heap / B-Tree) Column Store (values compressed)data page 1000 data page data page data page ProductID OrderDate Cost 2000 2001 2002 310 20010701 2171.29 ProductID OrderDate Cost 310 20010701 2171.29 311 20010701 1912.15 311 … 1912.15 312 20010702 2171.29 312 20010702 2171.29 313 … 313 20010702 413.14 413.14 314 … 333.42 315 20010703data page 1001 1295.00 316 …ProductID OrderDate Cost 4233.14 317 …314 20010701 333.42 641.22 318 … 319 24.95315 20010701 1295.00 … 320 20010704 64.32316 20010702 4233.14 321 … 1111.25 5317 20010702 641.22@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 6. Columnstore indexes Mobile & Development• Performance improvements for “typical” data warehouse queries from 10x to 100x• Ideal candidates include queries against star schemas that use filtering, aggregations and grouping against very large fact tables 6@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 7. Columnstore indexes Mobile & DevelopmentTechnologies:Storage• Data is stored in a compressed columnar data format (stored by column) instead of row store format (stored by row).• Columnar storage allows for less data to be accessed when only a sub-set of columns are referencedNew “batch mode” execution• Data can then be processed in batches (1,000 row blocks) versus row-by-row• Depending on filtering and other factors, a query may also benefit by “segment elimination” - bypassing million row chunks (segments) of data, further reducing I/O 7@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 8. Columnstore indexes Mobile & DevelopmentWhen to use itTable candidates:• Very large fact tables (for example – billions of rows)• Larger dimension tables (millions of rows) with compression friendly column dataQuery candidates (against table with a columnstoreindex):• Scan versus seek (columnstore indexes don’t support seek operations)• Sub-set of columns (being selective in columns versus returning ALL columns)• Single-column joins between columnstore indexed table and other tables 8@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 9. MICROSOFT SQL SERVER DATA TOOLS@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 10. Microsoft SQL Server Data Tools Mobile & DevelopmentSQL Server Data Tools (SSDT)• Formerly known as SQL Server Developer Tools, Code-Named “Juneau”.• SSDT is an evolution of the Visual Studio for Database Professionals ("Data Dude").• Development tool for the SQL Server and SQL Azure Database Developer.• Can be installed standalone or can be integrated into an existing Visual Studio 2010 installation (Pro and above).• It will also ship with the next major release of Visual Studio (Visual Studio 2011).@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 11. Microsoft SQL Server Data Tools Mobile & DevelopmentFeatures• Targets SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012 and SQL Azure• Migrate on-premise SQL Server schemas to the cloud on SQL• SQL CLR Development• Rich disconnected (project-based) development model – Code analysis – Dependency tracking – Refactoring – Intellisense• Connected model• Data-tier Application (DAC Fx) model – Script generation also possible@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 12. Microsoft SQL Server Data Tools Mobile & DevelopmentPLATFORM TARGETING• Single project can target multiple platforms − SQL Server versions − SQL Azure• Project build provides errors/warnings − Specific to target − No need to create and execute scripts to find issues@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 13. Microsoft SQL Server Data Tools Mobile & DevelopmentSQL Server Data Tools SQL CLR SupportSSDT supports adding SQL CLR objects to databaseprojects −No need for separate SQL CLR projects −C# and VB −Seamless debugging and deployment −SQLCLR properties tabs on database projects −Separate projects still supported@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 14. SQL SERVER EXPRESS LOCALDB@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 15. SQL Server Express LocalDB Mobile & Development• SQL Server edition aimed at developers – User-mode, in process execution – Zero configuration installation – Transparent database engine for embedding in applications – Minimal pre-requisites – Minimal files copied during deployment – Designed for use in multiple environments – Used as a test platform for developers – Embedded database for production applications – SQLLocalDB.exe utility for management – Replaces user instance support in SQL Express – SQL Express user instance support deprecated since SQL Server 2008 – Supports AttachDBFileName in connection string – Specify location of database files@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 16. SQL Server Express LocalDB Mobile & Development• Similar to working with other editions – Same SQLServr.exe executable – Same client-side providers – Same T-SQL• Installed once per version per machine – Applications each launch their own copies of exe• No services are installed – Processes started/stopped automatically as needed – Applications connect to "Data Source=(localdb)/v11.0" – LocalDB launched as a child process of the application – LocalDB process shuts down a few minutes after last connection drops@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 17. SQL Server Express LocalDB Mobile & DevelopmentFeature SQL Server SQL Server SQL Server SQL Server 2012 Compact 3.5 SP2 Compact 4.0 Express 2012 LocalDBDeployment/Installation FeaturesInstallation size 2.5 MB 2.5 MB 120 MB 32 MB download size download size download size download 12 MB 18 MB > 300 MB size > 160 expanded on expanded on expanded on MB on disk disk disk diskClickOnce deployment Yes Yes Yes YesPrivately installed, Yes Yes No Noembedded, with theapplication64-bit support Yes Yes Yes YesRuns as a service No – In process No - In process Yes No – as with application with launched application process@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 18. SQL Server Express LocalDB Mobile & DevelopmentFeature SQL Server SQL Server SQL Server SQL Server 2012 Compact 3.5 SP2 Compact 4.0 Express 2012 LocalDBData file featuresFile format Single file Single file Multiple files Multiple filesData file storage on a No No No Nonetwork shareSupport for different Yes Yes No Nofile extensionsDatabase size support 4 GB 4 GB 10 GB 10 GBXML storage Yes – stored as Yes - stored as Yes Yes ntext ntextBinary (BLOB) storage Yes – stored as Yes - stored as Yes Yes image imageFILESTREAM support No No Yes No@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 19. SQL Server Express LocalDB Mobile & DevelopmentFeature SQL Server SQL Server SQL Server SQL Server 2012 Compact 3.5 SP2 Compact 4.0 Express 2012 LocalDBProgrammabilityProcedural T-SQL - No No Yes YesSelect Case, If, featuresSimple transactions Yes Yes Yes YesDistributed No No Yes YestransactionsNative XML, No No Yes YesXQuery/XPathStored procedures, No No Yes Yesviews, triggersRole-based security No No Yes YesNumber of concurrent 256 (100) 256 Unlimited Unlimitedconnections (but only local)@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 20. T-SQL IMPROVEMENTS@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 21. T-SQL improvements Mobile & Development• Query Pagination• OVER Clause Windowing• Sequences• Metadata Discovery• Enhanced Function Library• Service Broker Enhancements• General T-SQL-Related Enhancements@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 22. T-SQL improvements Mobile & DevelopmentQuery PaginationSyntax: OFFSET <offset_value> ROW|ROWS FETCH FIRST|NEXT <fetch_value> ROW|ROWS [ONLY]Example: SELECT ProductID, Name,Color, Size FROM Production.Product ORDER BY Color,ProductID ASC OFFSET 100 ROWS FETCH NEXT 25 ROWS ONLY; END;@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 23. EXTENDED EVENTS ENHANCEMENTS@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 24. Extended Events enhancements Mobile & DevelopmentExtended Events• A general event-handling system for server systems.• It allows defining events to be monitored and provides a variety of ways to consume the events.• It can be synchronous or asynchronous (events are fired synchronously).• It can trigger actions when an event fires.• It uses predicates to filter events from consumers.• It has high performance and good scalability.• The cost of firing a single event is extremely small (approximately 2 μs CPU time on a 2 GHz processor).@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 25. Extended Events enhancements Mobile & DevelopmentExtended Events – what’s new• Management Studio provides support for Extended Events under the Management folder in Object Explorer – Target data can be read using the data viewer in Management Studio• NumberOfEventsMonitored+=hundreds (compared to SQL Server 2008)• Management API for .NET Extended Events support QueryableXEventData stream = new QueryableXEventData( @"Data Source = (local); Initial Catalog = master; Integrated Security = SSPI", "system_health", EventStreamSourceOptions.EventStream, EventStreamCacheOptions.DoNotCache);@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 26. Extended Events enhancements Mobile & DevelopmentExample DECLARE @dbid int = db_id(AdventureWorksDW2008) EVENT DECLARE @sql nvarchar(1024) = CREATE event session LockCounts ON SERVER ADD EVENT sqlserver.lock_acquired (WHERE database_id = + CAST(@dbid AS nvarchar) +) ADD TARGET package0.synchronous_bucketizer ( TARGET SET filtering_event_name=sqlserver.lock_acquired, source_type=0, source=resource_0); EXEC (@sql); GO ALTER EVENT session LockCounts ON SERVER STATE=start; GO@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 27. Extended Events enhancements Mobile & DevelopmentExample SELECT name, object_id, lock_count FROM (SELECT objstats.value(.,bigint) AS lobject_id, objstats.value(@count, bigint) AS lock_count FROM ( SELECT CAST(xest.target_data AS XML) LockData FROM sys.dm_xe_session_targets xest JOIN sys.dm_xe_sessions xes ON xes.address = xest.event_session_address JOIN sys.server_event_sessions ses ON xes.name = ses.name WHERE xest.target_name = synchronous_bucketizer AND xes.name = LockCounts ) Locks CROSS APPLY LockData.nodes(//BucketizerTarget/Slot) AS T(objstats) ) LockedObjects INNER JOIN sys.objects o ON LockedObjects.lobject_id = o.object_id WHERE o.type != S AND o.type = U ORDER BY lock_count desc;@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 28. Extended Events enhancements Mobile & DevelopmentExample -- -- Stop the event session. -- ALTER EVENT SESSION LockCounts ON SERVER state=stop; GO@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 29. Extended Events enhancements Mobile & DevelopmentIf a picture is worth a thousand words …… a 5 minute demo is worth ??? 150.000 words(using the assumption that the human eyeneed at least 500 fps to perceive reality withoutany distortion)@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 30. SQL SERVER 2012 CERTIFICATION@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 31. SQL Server 2012 certification Mobile & Development• MCSA - Microsoft Certified Solutions Associate• MCSE - Microsoft Certified Solutions Expert• MCSD - Microsoft Certified Solutions Developer• MTA - Microsoft Technology Associate• MCSM – Microsoft Certfied Solutions Master@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 32. SQL Server 2012 certification Mobile & Development Microsoft Microsoft Cloud- Certifications built Certifications MCM (Master) MCSM (Solutions Master) Master MCITP (IT MCSE (Solutions Professional) Expert) MCPD MCSD (Professional (Solutions Expert Developer) Developer) MCTS MCSA (Solutions (Technology Associate) Specialist) Associate@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 33. SQL Server 2012 certification Mobile & DevelopmentWarning:You can complete your MCITP or MCTS on SQLServer 2008 until July 2013@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 34. NEXT STEPS@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 35. Next Steps Mobile & Development• SQL Server 2012 Update for Developers Training Workshop http://bit.ly/sql2012ro• SQL Server Virtual Labs http://www.microsoft.com/sqlserver/en/us/le arning-center/virtual-labs.aspx• Migrating from SQL Trace to Extended Events Mike Wachal’s Blog• ROSQL http://sqlserver.ro@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 36. Q&A@ itcampro # itcamp12 Premium conference on Microsoft technologies