This document provides an overview of new features in SQL Server 2005, including SQLCLR which allows writing functions, procedures and triggers in .NET languages. It discusses how to install and debug SQLCLR assemblies, and create user-defined data types and aggregates that can extend the functionality of SQL Server. Key enhancements to T-SQL are also summarized, such as common table expressions, ranking commands, and exception handling.
Once the ‘Backup Database’ command executed, SQL Server automatically does few ‘Checkpoint’ to reduce the recovery time and also it makes sure that at point of command execution there is no dirty pages in the buffer pool. After that SQL Server creates at least three workers as ‘Controller’, ‘Stream Reader’ and ‘Stream Writer’ to read and buffer the data asynchronously into the buffer area (Out of buffer pool) and write the buffers into the backup device.
- The document discusses the basics of Windows clustering and quorum models. It defines what clustering is and why it is used for high availability of critical applications.
- It covers the differences between Windows 2008 and 2012 clustering capabilities. Windows 2012 supports more nodes, built-in iSCSI, and file/storage services.
- Common clustering terms are defined like active/passive, heartbeat network, shared disks, quorum, cluster resources, and groups.
- Quorum configuration options are reviewed including typical settings, adding witnesses, and advanced configurations. Quorum helps ensure only one cluster remains active if communication is lost.
SQL Server High Availability Solutions (Pros & Cons)Hamid J. Fard
Proper SQL Server High Availability Solution Is Highly Depends on the Business Objective and IT Operation Objectives. It Happens Sometimes that We Might Have Few Solutions on the Table to Implement.
Database mirroring allows for high availability and protection of SQL Server databases. It requires at least two SQL servers - a principal database and mirror database. A witness server is also used to automate failover between the principal and mirror databases. The document outlines the implementation steps, which include preparing the servers, backing up the principal database and transaction log, restoring the backup on the mirror server, and configuring security and mirroring settings between the principal, mirror and witness servers. Once setup is complete, the databases are mirrored and failover can occur automatically using the witness server.
This document provides an overview of SQL Server clustering. SQL Server clustering uses Microsoft clustering services (MSCS) to set up a highly available Windows cluster for mission critical databases. There are two main failover configurations - active/passive where only one node is active and active/active where both nodes are active. The top three challenges to implementing a cluster are managing CPU, memory, and disk resources to allow for failover without degrading performance. Proper planning and design is important to ensure a smooth clustered SQL Server environment.
The document discusses SQL Server monitoring and troubleshooting. It provides an overview of SQL Server monitoring, including why it is important and common monitoring tools. It also describes the SQL Server threading model, including threads, schedulers, states, the waiter list, and runnable queue. Methods for using wait statistics like the DMVs sys.dm_os_waiting_tasks and sys.dm_os_wait_stats are presented. Extended Events are introduced as an alternative to SQL Trace. The importance of establishing a performance baseline is also noted.
- Oracle Database 11g Release 2 provides many advanced features to lower IT costs including in-memory processing, automated storage management, database compression, and real application testing capabilities.
- It allows for online application upgrades using edition-based redefinition which allows new code and data changes to be installed without disrupting the existing system.
- Oracle provides multiple upgrade paths from prior database versions to 11g to allow for predictable performance and a safe upgrade process.
- SQL Server 2016 enhances AlwaysOn availability groups by allowing up to two additional secondary replicas for failover purposes, improving high availability.
- It introduces load-balanced read-only replicas that can distribute read-only workloads across multiple secondaries in a round-robin fashion.
- Distributed transaction support is now provided for AlwaysOn when using Windows Server 2016 and SQL Server 2016.
1. SQL Server performance on VMware was tested and found to achieve equivalent or better performance than physical hardware, with 10x better disk subsystem I/O performance.
2. Critical SQL performance counters were monitored and maintained acceptable levels.
3. Consolidating multiple SQL VMs onto fewer physical servers through virtualization can save significant costs on hardware, space, power and cooling while providing high availability and disaster recovery.
SQL Server 2016 AlwaysOn Availability Groups New FeaturesJohn Martin
This deck was presented at SQL Relay 2015 in Bristol;
In this deck we will look at some of the new capabilities that are slated for release as part of the Microsoft SQL Server 2016 platform.
Demo code for this deck can be found at: http://1drv.ms/1PC8707
SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)webhostingguy
This document provides an overview of programming the Common Language Runtime (CLR) in SQL Server 2005. It discusses how CLR integration works, the different ways to use managed code like C# in SQL Server through stored procedures, functions, triggers and other means. It also covers deployment, monitoring, performance considerations and questions.
The presentation introduces SQLCLR, which allows developers to write .NET code in SQL Server 2005. It discusses developing and managing SQLCLR applications, monitoring performance, and best practices. SQLCLR enables rich functionality within the database by running .NET code, but requires careful management to avoid potential security and performance issues. The speaker demonstrates examples using SQLCLR for string manipulation and custom aggregates.
The presentation introduces SQLCLR, which allows developers to write .NET code in SQL Server 2005. It discusses developing and managing SQLCLR applications, monitoring performance, and best practices. SQLCLR enables rich functionality within the database by running .NET code, but also presents security and management challenges that require care and oversight. The speaker demonstrates examples of SQLCLR applications and stresses the importance of transparency, testing, and teamwork between developers and database administrators.
This document contains notes from a SQL Server 2008 for Developers course taught by Peter Gfader. The course covered topics such as high availability, online index operations, mirrored backups, and SQL CLR integration. SQL CLR integration allows writing database queries using .NET code. It provides benefits like complex calculations, custom types and aggregates, and leveraging .NET debugging. However, T-SQL is better suited for core data operations. The document provides examples of stored procedures, functions, triggers and other SQL CLR code.
The document summarizes features of SQL Server 2005 Mobile Edition and the .NET Compact Framework v2.0 for accessing data. It discusses the architecture, integration with SQL Server 2005 and Visual Studio 2005, and synchronization options including remote data access and merge replication. Key points covered include improved performance, query optimization, updated cursors, and ease of development in Visual Studio 2005.
Microsoft released SQL Azure more than two years ago - that's enough time for testing (I hope!). So, are you ready to move your data to the Cloud? If you’re considering a business (i.e. a production environment) in the Cloud, you need to think about methods for backing up your data, a backup plan for your data and, eventually, restoring with Red Gate Cloud Services (and not only). In this session, you’ll see the differences, functionality, restrictions, and opportunities in SQL Azure and On-Premise SQL Server 2008/2008 R2/2012. We’ll consider topics such as how to be prepared for backup and restore, and which parts of a cloud environment are most important: keys, triggers, indexes, prices, security, service level agreements, etc.
- The document provides a history of Microsoft SQL Server, from its initial release in 1988 in partnership with Sybase through subsequent versions released through 2005. It also summarizes new features introduced in SQL Server 2005, including common table expressions, improved error handling, DDL triggers, query notifications, the ROW_NUMBER() function, and PIVOT operators.
- SQL Server 2005 introduced several new features to improve functionality, including common table expressions, improved error handling using TRY/CATCH blocks, DDL triggers to monitor database/table/user creations, query notifications to reduce application round trips to the database, and new functions like ROW_NUMBER() and PIVOT operators.
- The document covers the history
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
Oracle Database 12c includes over 500 new features designed to support cloud computing, big data, security, and availability. Key features include support for up to 4096 pluggable databases, hot cloning without placing the source database in read-only mode, sharding capabilities, in-memory column storage, application containers, improved resource management isolation, and AWR support on Active Data Guard databases. Other notable features include enhanced JSON support, data redaction for security, row limits and offsets for queries, invisible columns, SQL text expansion, PL/SQL from SQL, session-level sequences, extended data types up to 32K, multiple indexes on the same columns, READ privileges without row locking ability, session private statistics for global temporary tables,
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
This document summarizes a presentation about new features in Oracle Database 12c for developers and DBAs. It introduces JSON support, data redaction, SQL query row limits and offsets, invisible columns, extended data types, session level sequences, and more. Demo sections are included to illustrate several of the new features.
This document provides an overview of SQL Server DBA training topics including:
- Installing and configuring SQL Server, choosing the appropriate edition, and installing service packs
- Security concepts including logins and users
- Administrative tasks such as backups, restores, monitoring, and high availability that DBAs are responsible for
This document provides an overview of SQL Server DBA training topics including:
- Installing and configuring SQL Server, including choosing an edition, installation process, and configuring services
- Security topics such as logins and users
- Additional administrative tasks like managing database files, backups, restores, monitoring, maintenance plans, and high availability options
- Appendices with differences between SQL and Oracle and an installation guide with screenshots
This document discusses CLR integration in SQL Server 2008, which allows developers to create database objects using managed code in .NET languages. It provides advantages over T-SQL, including support for object-oriented programming, collections, and access to the .NET framework. The document outlines the steps to implement CLR integration, including creating an assembly in a .NET language, importing and configuring the assembly in the SQL Server database, and creating database objects like triggers, functions, and procedures that reference the managed code. CLR integration allows running complex managed code logic within the database for tasks not easily done in T-SQL.
This document provides an overview of programmability options in SQL Server 2005, including Transact-SQL, extended stored procedures, OLE automation, and SQLCLR. It discusses SQLCLR architecture and security model and how to create managed objects like stored procedures, functions, triggers, user-defined types, and aggregates. It also covers best practices like using T-SQL for data access and calling stored procedures from managed code.
Web Cloud Computing SQL Server - Ferrara Universityantimo musone
The document provides a summary of an individual's background and experience. It includes the following information in Italian:
1. The individual graduated from the University of Ferrara in 2014 and is an engineer from the University of Naples. They have worked at Avanade since 2006 as a Technical Architect focusing on Cloud and Mobile.
2. They speak at events as a Microsoft Student Partner and are a co-founder of the Fifth Element Project.
3. Their areas of expertise include applications, storage, servers, networking, operating systems, databases, virtualization, runtimes, middleware, and infrastructure as a service, platform as a service and software as a service.
4. They provide a link to
We are Providing #FREE #SQL #Database #Training to students.. Registration Fees Apply
For Registration Call us : 8087155500 / 8149775757
Java,PHP,UIDesign,.Net,Adnroid,Softwaretesting
Encryption Technology
Above Jijamata Bank, 4rth Floor, Near Karve Nagar Bus stand, Pune
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
This document provides an overview of new features in Oracle Database 12c for developers and DBAs. It begins with an introduction by Alex Zaballa and then covers several new features including native support for JSON, data redaction, row limits and offsets for SQL queries, PL/SQL functions callable from SQL, session level sequences, and temporary undo. The document includes demonstrations of many of these new features.
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
Oracle Database 12c introduces many new features for developers and DBAs. These include native support for JSON, data redaction capabilities, improved SQL query functionality using row limits and offsets, and new PL/SQL features like calling functions from SQL. The presentation provides demonstrations of these new features.
The document provides an overview of new features in SQL Server 2005 including enhanced XML support, CLR integration, and Service Broker. XML features allow storing and querying XML data natively using XML data types and indexes. CLR integration allows writing database objects in .NET languages. Service Broker introduces asynchronous messaging capabilities.
1) File uploads in PHP require configuring php.ini settings like enabling file uploads and setting temporary storage directories with correct permissions.
2) Forms for file uploads need to use POST with multipart/form-data encoding and include file input fields and hidden fields.
3) PHP stores uploaded files in the $_FILES array, including the temporary filename, size, type, and original name, which can then be processed and moved to a permanent location.
Running and Developing Tests with the Apache::Test Frameworkwebhostingguy
The Apache::Test framework allows running and developing tests for Apache modules and products. Key features include:
- Running existing tests through the t/TEST program
- Setting up a new testing environment by installing Apache::Test and generating a Makefile
- Developing new tests by writing Perl scripts that use Apache::Test functions and assert results
- Options for running tests individually, repeatedly without restarts, or in parallel on different ports
This document provides instructions on installing and configuring memcached to improve the performance and scalability of MySQL. Memcached is installed using package managers or by compiling from source. It is configured to listen on ports and interfaces, allocate memory, and set thread counts. The typical usage involves applications loading data from MySQL into memcached for faster retrieval, with MySQL as the backing store if data is not found in the cache.
The document discusses Novell iChain, a solution for securing web applications and servers. It provides single sign-on, encrypts data as it passes through proxies, and removes direct access to web servers. It authenticates users through LDAP or certificates and authorizes access through rules stored in eDirectory. This simplifies management and security across multiple web server platforms and applications.
Load-balancing web servers Load-balancing web serverswebhostingguy
The document discusses different approaches to load balancing web servers to address issues like scaling performance, tolerating failures, and rolling upgrades. It describes three common solutions: redirecting requests through a front-end server; using round-robin DNS to distribute requests; and employing an intelligent load balancer switch that can distribute requests based on server load and detect failures. Each approach has advantages and disadvantages related to ease of implementation, visibility to users, and ability to handle session state. The document also discusses network designs and protocols involved in load balancing, including TCP connection setup and teardown.
The document compares three methods for consolidating SQL Server databases: 1) multiple databases on a single SQL Server instance, 2) a single database on multiple SQL Server instances, and 3) hypervisor-based virtualization. It finds that consolidating multiple databases onto a single instance has the lowest direct costs but reduces security and manageability. Using multiple instances improves security but has higher resource needs. Hypervisor-based virtualization maintains security while enabling features like high availability, but has higher licensing costs. The document aims to help decide which approach best balances these technical and business factors for a given environment.
Mod_perl brings together the Apache web server and Perl programming language. It allows Apache to be configured and extended using Perl, and significantly accelerates dynamic Perl content. Mod_perl supports Apache versions 1.3 and 2.x and integrates Perl at every stage of the request process to provide great flexibility and control over Apache functionality. The mod_perl community provides extensive documentation and quick support responses.
Mod_perl brings together the Apache web server and Perl programming language. It allows Apache to be configured and extended using Perl, and significantly accelerates dynamic Perl content. Mod_perl supports Apache versions 1.3 and 2.x and integrates Perl at every stage of the request process to provide great flexibility and control over Apache functionality. The mod_perl community provides extensive documentation and quick support responses.
The document discusses various aspects of designing an effective website, including analyzing content and target audiences, organizing site structure and navigation, and implementing design elements. The key steps outlined are to analyze content and audience needs, organize the site structure into main sections and subsections, and implement an intuitive navigation system to help users easily find relevant information. Maintaining and optimizing the site over time are also emphasized.
This white paper provides an architectural overview and configuration guidelines for deploying Microsoft SQL Server 2005 with Microsoft Windows Server 2008 on Dell PowerEdge servers and Dell storage systems. It documents best practices for implementing SQL Server 2005 solutions using Dell hardware and software components that have been tested and validated to help ensure successful deployment and optimal performance. The white paper covers storage configuration, network configuration, operating system configuration, and SQL Server configuration recommendations.
1. The document discusses the evolution of business models for IT infrastructure from proprietary systems within individual companies to more open standards and shared infrastructure leveraging the internet.
2. It describes new service models like client-server computing, web services, and on-demand/utility computing which allow flexible provisioning of computing resources on a needs basis.
3. Managing diverse IT infrastructures requires considerations around outsourcing non-core functions, developing service level agreements, managing legacy systems, and aligning infrastructure capabilities to business strategy through appropriate investment.
The document discusses different types of websites that can be created for business purposes including traditional, blog-based, and group/network sites. It provides information on setting up each type of site for free or at low cost using online tools or designers, and how to add features like domains, payment systems, and linking domains to sites. Options for free and cheap site creation using tools like Google Sites are demonstrated.
This document outlines Saint Louis University's strategy for improving power management of IT equipment to reduce costs and environmental impact. Key points include:
1) SLU aims to standardize power-optimized default settings on all managed PCs and laptops through automated software and establish policies around exceptions and existing devices.
2) Potential savings are estimated from generational improvements in computer hardware and adopting lower-power modes like sleep versus screensavers.
3) The strategy also involves consolidating servers, enabling energy-efficient settings on printers and other electronics, and establishing institutional goals around student computer energy use.
Excel and SQL Quick Tricks for Merchandiserswebhostingguy
This document provides instructions for using Microsoft SQL and Excel to extract data from a SmartSite SQL database, manipulate it in Excel using functions, and update the SQL tables with the modified data to streamline content work. It covers connecting to and querying SQL databases, common Excel functions for editing data, and steps for importing an Excel file into a SQL table to update information. Examples of specific SQL queries and Excel functions are provided along with a scenario walking through the full process.
The document discusses various topics related to virtualization including drivers for virtualization, practical applications, definitions of terms like virtualization and paravirtualization, and tools like Xen, VMWare, and Microsoft virtualization products. It provides information on installing and configuring Xen on SuSE Linux, discusses security and auditing considerations for Xen, and demonstrates Xen functionality.
The document discusses strategies for converting low-value hosting clients into high-value customers by marketing additional services. It recommends continuously marketing to clients through email, forums, blogs and surveys to promote add-on services like collaboration tools, applications, and infrastructure-as-a-service offerings which can significantly increase revenue per client. Measuring marketing campaigns and conversions is key to optimizing efforts to up-sell existing clients.
Microsoft PowerPoint presentation 2.175 Mbwebhostingguy
The document discusses WebMapping Solutions and their products and services. It summarizes their middleware and mapping tools like MapBroker, Generic GUI Builder, and MapOrganiser. MapBroker powers many of their applications. Their products allow users to build custom web mapping applications and manage both geographic and non-geographic data in a single view. Their services include publishing data online, application development, and strategic consulting. Some examples of government and organization clients are listed.
This document provides an overview and guide for using HSPcomplete, a hosting automation solution that allows hosting service providers to manage infrastructure, billing, sales channels, and e-commerce through a single system. It describes HSPcomplete's advantages like integrated billing and credit card processing, virtual private server management, and domain registration. Hardware, software, and user requirements for HSPcomplete deployment are also outlined.
1. You Can Do Anything If You Think “Yukon” Presented by: Richard Broida Senior Architect
2. Agenda Overview of SQL Server 2005 Enhancements to Database Engine and T-SQL CLR Hosting Writing CLR functions, procedures and triggers Creating user-defined data types and aggregates Resources Q & A
3. History of Microsoft SQL Server 1988 – MS/Sybase version for OS/2 1993 – 4.21 for NT 3.1 1994 – MS/Sybase partnership ends 1995 – 6.0, major rewrite 1996 – 6.5 1997 – 6.5 Enterprise Edition 1998 – 7.0, total rewrite 2000 – 2000
4. SQL Server 2000 Has Lived to See … Windows XP and Windows 2003 Server .NET Framework 1.0 and 1.1 BizTalk 2000, 2002 and 2004 Commerce Server 2000 and 2002 CMS 2000 and 2003 SharePoint 2001 and 2003 Exchange Server 2000 and 2003 Oracle 9i and 10g DB2 8.1 and 8.2
5. New Features in SQL Server 2005 SQLCLR XML as Native Data Type Hosting Web Services Enhancements to T-SQL Client API Enhancements Service Broker Notification Services Enhanced Reporting Services Enhanced Analysis Services
6. SQL Server 2005 Editions Express Edition Replaces MSCE Freely downloadable and redistributable Workgroup Edition Less expensive than Standard Standard Edition Enterprise Edition Developer Edition
7. Where is It Now? First Technology Preview released at PDC in October 2003 Betas 1 and 2 Released in 2004 Most current version on MSDN is February 2005 Community Technology Preview A “Beta 3” was announced for April 2005 release, along with Beta 2 of Visual Studio 2005. Not out yet.
8. Big Disclaimer This presentation is based on the February 2005 Community Technology Previews of SQL Server 2005 and Visual Studio 2005. Anything and everything could change between now and the final release of these products. To the extent of such changes, the information in this presentation could end up wrong!
9. Beta/CTP Installation Tips Use a clean VM Or, completely remove old build before installing new one using etup Toolsuild Uninstall Wizardqlbuw.exe in installation media Install SQL Server and Visual Studio on separate VMs They tend to have incompatible builds of the CLR Even on separate VMs, not all Yukon/Whidbey combinations work together. These do: Yukon Beta 1 with Whidbey Beta 1 Yukon Dec CTP with Whidbey Oct CTP Yukon Feb CTP with Whidbey Feb CTP
11. Does a SQL Server 2005 Programmer Need to Know T-SQL? Absolutely! SQLCLR relies on T-SQL for querying and updating the database T-SQL is still the fastest and most powerful for what it does New T-SQL enhancements reduce the situations where procedural code is necessary
12. Enhancements to the Database Engine SNAPSHOT Isolation Level Uses versioning instead of locks, like that “Greek” database Can provide better concurrency than traditional SERIALIZABLE and READ_COMMITTED Large Value Data Types VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) can hold up to 2 31 bytes Use instead of TEXT and IMAGE Statement-Level Recompilation for SPs
13. Enhancements to T-SQL TRY … CATCH Exception Handling With support for Transactions OUTPUT Command Use with INSERT, UPDATE and DELETE to save copies of the affected rows in a temporary table TOP Command Supported in INSERT, UPDATE and DELETE Quantity can be a calculated value PIVOT command Rotates rows into columns and columns into rows
14. Common Table Expressions The “WITH” Clause Creates a “virtual” table for use in a single query Often provides a simpler syntax than using a VIEW or subquery, and may be easier for Optimizer to optimize Allows recursive queries
15. Simple WITH Clause WITH BigSales(RepID) AS (SELECT RepId from Sales WHERE TotSales > 50000) SELECT ‘Big Seller’, * FROM SalesReps WHERE SalesReps.Id = BigSales.RepId UNION SELECT ‘Small Seller’, * FROM SalesReps WHERE SalesReps.Id NOT IN (SELECT RepId FROM BigSales)
16. Recursion Example: a “Linked List” Table: OrgChart ID Name ReportsTo 1 Dubya NULL 2 Bill 3 3 Rama 1 4 Sal 2 5 Jane 3 6 Shu 1
17. Query: How Many Levels from the Top Are You? Levels From Top Dubya 0 Rama 1 Shu 1 Bill 2 Jane 2 Sal 3
18. Performing the Query WITH LevelsDown (Id, Tot) AS ( SELECT Id, 0 FROM OrgChart WHERE ReportsTo is NULL UNION ALL SELECT OrgChart.Id, LevelsDown.Tot + 1 FROM LevelsDown JOIN OrgChart ON LevelsDown.Id = OrgChart.ReportsTo ) SELECT Name, Tot FROM OrgChart JOIN LevelsDown ON OrgChart.ID = LevelsDown.Id ORDER BY 2
19. New Ranking Commands Require an OVER clause to specify the sorting order ROW_NUMBER Inserts a column showing absolute position in the sort order RANK Assigns same value to all rows with same rank in the sort order DENSE_RANK Like RANK, but doesn’t leave “holes” NTILE Divides results into equal or near-equal divisions Great for efficient paging in a DataGrid
20. Adding Row Numbers to Query Output SELECT ROW_NUMBER() OVER( ORDER BY L ast N ame) AS RowNumber, F irst N ame, L ast N ame FROM P erson
21. Selecting the 78 th of 83 “Pages” of Data SELECT LastName, FirstName FROM ( SELECT NTILE( 83 ) OVER (ORDER BY LastName) AS PageNo, FirstName, LastName FROM Person ) AS TEMP WHERE TEMP. PageNo = 78
23. Overview of SQLCLR Write Procedures, Triggers and Functions in .NET languages to run in a CLR hosted by SQL Server Use ADO.NET data access classes to run T-SQL commands inside the server Create User-Defined Data Types that can be stored in database tables Write Aggregate functions to operate on UDTs
24. Procedural Database Code before SQLCLR T-SQL Clumsy syntax Slow when not dealing directly with the database Syntax unfamiliar to many programmers Extended Stored Procedures Write an external DLL in C Supported in SQL Server 2005, but likely to be deprecated Difficult to develop and test Risky, because external DLL runs in SQL Server’s address space Memory leaks Database corruption Security holes External Code in Data Access, Business Logic and/or Presentation layers
25. Benefits of SQLCLR Write in your favorite .NET language Initially supports C#, VB.NET and C++ Use any .NET development tools Use Framework Class Library or other libraries Computation-intensive code executes faster than T-SQL Stability and security of the CLR Use native SQL security, Code Access Security, or both
26. What is a CLR Host? Host: Any process that loads the CLR .NET Framework 1.x has three hosts: Command shell IIS Internet Explorer Can write other CLR hosts using the Hosting API .NET Framework 2.0 expands the Hosting API to accommodate the needs of SQL Server
27. Requirements for Hosting in SQL Server To maximize performance, SQL Server manages its own memory and threads without help from the NT Kernel SQL Server understands internal memory needs better than NT Kernel; can use memory more efficiently with less paging SQL Server uses cooperative multitasking to switch threads without kernel-mode context switching Or in “fiber mode”, SQL Server may use fibers instead of threads Requires multi-CPU machine
28. How SQL Server Implements CLR Hosting SQLCLR memory management is handled by SQL Server, not NT Kernel SQLCLR threads come from SQL Server thread pool and are cooperatively multitasked Or if SQL Server is in “fiber mode”, the CLR threads are actually fibers SQLCLR stores assemblies inside the database and loads them from there, not from the file system
29. Permission Sets Defined for SQLCLR Assemblies SAFE The default Restrictions to assure the stability and security of SQL Server EXTERNAL_ACCESS Can access external data sources UNSAFE No restrictions, except those imposed by .NET Framework on all managed code Similar risks as unmanaged External Stored Procedures
30. SAFE Permission Set Prohibited to Create threads Access external resources such file system, network, registry or environment variables Connect to external databases Call unmanaged code via PInvoke or RCWs Call portions of the Framework Class Library not marked as safe for SQL Server E.g., System.Windows.Forms, System.Security, System.Reflection
31. EXTERNAL_ACCESS Permission Set Permitted to Access external resources such as file system, network, registry or environment variables Connect to external databases Everything else prohibited same as SAFE
32. Some Consequences of SQL Server Hosting Static fields must be readonly After try{}, a finally{} block is not guaranteed to be called
33. How to Install an Assembly in SQLCLR Create the Assembly outside SQL Server SQL Server itself comes with no tools to write or compile assemblies. Can use Visual Studio, Framework SDK, or other tools SQL Server doesn’t need a Strong Name Enable SQLCLR on the server Install Assembly in SQL Server with CREATE ASSEMBLY Declare a procedure, function or trigger with CREATE [PROCEDURE|FUNCTION|TRIGGER] … EXTERNAL NAME …
34. Enabling SQLCLR on a Server CLR Execution is Disabled by Default To enable it, execute: Sp_configure ‘clr enabled’, 1 RECONFIGURE
35. Installing An Assembly CREATE ASSEMBLY MyAssembly FROM ‘C:rojectsinyAssembly.dll’ WITH PERMISSION_SET = SAFE ALTER ASSEMBLY MyAssembly FROM ‘C:rojectsinyAssembly.dll’ WITH PERMISSION_SET = SAFE DROP ASSEMBLY MyAssembly
36. Making the Assembly Usable from T-SQL CREATE PROCEDURE MyProcedure (@arg1 int, @arg2 varchar(20)) EXTERNAL NAME MyAssembly.[MyNameSpace.MyClass]. MyProcedure CREATE FUNCTION MyFunction (arg1 int) RETURNS int EXTERNAL NAME MyAssembly.[MyNameSpace.MyClass]. MyFunction
37. Viewing Assemblies in SQL Server’s Metadata To view metadata about assemblies installed in SQL Server SELECT * FROM Sys.Assemblies To view assembly code itself SELECT * FROM Sys.Assembly_Files To view procedures, functions and triggers defined from an assembly SELECT * FROM Sys.Assembly_References
39. SQL Database Projects in Visual Studio 2005 Allow quick creation of classes for Stored Procedures, Functions, Triggers, UDTs and Aggregates One-click deployment of assembly into a database, no need to write T-SQL code SQL Script provided to run while debugging
40. Debugging SQLCLR Visual Studio 2005 Interactive Debugger can step through SQLCLR code Must have Visual Studio Remote Debugging Monitor running on remote SQL Server Microsoft has announced intention to release a free stand alone debugger sometime after SQL Server 2005 ships
41. Creating SQLCLR Functions, Procedures and Triggers Must be a static method with one of [SqlFunctionAttribute] [SqlProcedureAttribute] [SqlTriggerAttribute] Can belong to a class or struct, whose name isn’t important SQL doesn’t support overloading, so avoid overloaded method names
42. Using SQL Data Types in .NET SQL types don’t map perfectly to CTS types All SQL types can be NULL, but CTS value types can never be null SQL decimal has a broader range of values than CTS Decimal CTS Float and Double can hold the values Infinity and NAN, but SQL float and double cannot
43. System.Data.SqlTypes System.Data.SqlTypes implements SQL types in .NET SqlTypes should be used for Parameters to functions and stored procedures Return values from functions You can also use SqlTypes in code outside SQL Server
45. Operations on SqlTypes Numerical SqlTypes support unary and binary arithmetic operators (+,-,* etc) SqlTypes have boolean IsNull property Use it instead of comparing a SqlType with CLR null SqlTypes support comparison operators (==,!=,<,> etc), but watch out for special rules when value = NULL SqlTypes have static Null method to create an instance with value = NULL SqlString has concatenation with +
46. Converting SqlType to CLR Type void foo( SqlInt32 sqlInt ) { Int32 clrInt; clrInt = sqlInt.Value; // or clrInt = (Int32)sqlInt; // but next is error, no implicit conversion clrInt = sqlInt; }
47. Converting CLR Type to SqlType void foo( Int32 clrInt ) { SqlInt32 mySqlInt; mySqlInt = new SqlInt32(clrInt); // or mySqlInt.Value = clrInt; // or mySqlInt = (SqlInt)clrInt; // ok, implicit conversion allowed this direction mySqlInt = clrInt }
49. Accessing the Database from SQLCLR Code Database code written in T-SQL can issue SQL statements like SELECT, UPDATE and EXEC at any time SQLCLR code must go through an ADO.NET data provider
50. The System.Data.SQLServer Provider (as of Feb 2005 CTP) System.Data.SqlServer provides data access classes for use (only) within SQLCLR Connection objects aren’t needed Static SqlContext methods create commands, DataAdapters, etc In SAFE assembly, SQL Server won’t allow data access unless class has this attribute property: DataAccess=DataAccessKind.Read
51. Changes Coming Microsoft announced that in next pre-release of SQL Server 2005, System.Data.SqlServer will merge into System.Data.SqlClient To connect to the database from within SQLCLR, you will use a SQLConnection with this connection string: “context connection=true”
52. Data Access Example (Feb CTP) SqlCommand comm = SqlContext.CreateCommand(); comm.CommandText = “SELECT * FROM MyTable”; SqlDataReader reader = comm.ExecuteReader(); // use the reader …
53. Data Access Example (Coming Soon) SqlConnection conn = new SqlConnection(“context connection=true”) SqlCommand comm = new SqlCommand() comm.Connection = conn; comm.CommandText = “…”; conn.Open(); // use the command …
54. Splitting the SqlCommand SQLDefinition – the parts of the command that don’t change in multiple invocations SQLExecutionContext – the parts that do, such as the parameters These can yield better performance than a single SqlCommand
55. SqlPipe Returns a TDS (tabular data set) stream to the client Use to return the results of stored procedures to clients SqlDataReader reader = command.ExecuteReader(); SqlPipe pipe = SqlContext.GetPipe(); pipe.Send( reader );
56. Demonstration Executing SELECT statement inside a SQLCLR Function Putting It Together: Selecting a Random Row from a Table
58. Is SQL Server 2005 an Object-Oriented Database? No Will not store any arbitrary CLR type in the database Does not support inheritance or polymorphism It will store User-Defined Types, which emulate native SQL scalar types Though created in .NET, UDTs behave more like SQL types than OOP types
59. What is a User-Defined Data Type? A UDT is a .NET Class or Struct that can function as a SQL scaler type A scaler can be stored in a column of a table, or be the type of a variable Examples of built-in scaler types INT CHAR DATETIME
60. What Must a Scaler Be Able to Do? Mandatory Be serializable to/from a byte array Be serializable to/from a string Be able to equal NULL Optional, But Usually Necessary Support comparison operators (=,<,>, etc) Support numerical operators (+,-,*,/ etc) Support aggregation functions Be indexable
61. Creating a UDT Can be a Class or Struct Must have [SqlUserDefinedAttribute] Must implement INullable Must override ToString() Must have a static Parse() that converts a string to an instance of the UDT
62. Binary Serialization of UDTs Byte stream cannot exceed 8,000 bytes If [SqlUserDefinedAttribute] is set to Format.Native, SQL Server will handle serialization All UDT fields must be “blittable” I.e., fields that are simple value types Sort order must be based on order of the binary fields Use Format.Native whenever possible
65. UDTs Outside the Database Clients outside the database will need UDT type information when they see a table with a UDT column, and they won’t get the info from SQL Server You’ll need to deploy the UDT’s assembly in the client’s folder, in the GAC, or elsewhere in the probe path This leads to possible version conflicts between assemblies in and out of database
66. What is an Aggregate? A class or struct whose methods implement a SQL aggregation function The aggregation function can be applied in a T-SQL statement to a database column Example: SELECT MyAgg.Sum(MyTable.UDTCol) FROM MyTable
67. Creating an Aggregate Class or struct must have [SerializableAttribute] Class or struct must have [SqlUserDefinedAggregateAttribute] Must provide four public methods: Init Accumulate Merge Terminate
68. Aggregate Attribute Properties IsInvariantToNulls The aggregate ignores null values. The optimizer can choose not to send nulls. IsInvariantToDuplicates The aggregate ignores duplicate values. The optimizer can choose not to send dupes. IsInvariantToOrder The result is unaffected by the order in which rows are processed. Optimizer can send them in any order IsNullEmpty Result is NULL if no rows are passed. Optimizer can choose not to create an aggregate at all.
70. Microsoft SQL Server Summit 2005 With Karen Delaney, author of Inside SQL Server 2000 and Inside SQL Server 2005 May 17, 2005 Park Center III 6050 Oak Tree Blvd, Suite 300 Independence, Ohio 44131 Event code: 1032271939 To register call 1.877.673.8368 Free, but seating limited
71. Resources on the Web SQL Server 2005 Official Site http://msdn.microsoft.com/SQL/2005/default.aspx SQLJunkies http://www.sqljunkies.com/ SQL Server 2005 Hands-On Labs Online http://msdn.microsoft.com/sql/2005/2005labs/default.aspx
72. Conclusion SQL Server 2005 confirms Microsoft’s ongoing commitment to the product Gets closer to parity with rival databases SQLCLR has compelling advantages in some situations Intensive computations in memory Use of FCL library features In other situations, alternative designs, including T-SQL, may be better
73. Conclusion SQLCLR solutions require care to build and test SQLCLR developers will need mastery of both SQL and CLR