.NET S EFFECTS ON SQL SERVER AppDomain are part

.NET S EFFECTS ON SQL SERVER AppDomain are part of the same process. Unlike the technique used to isolate stored procedures, the AppDomain protects SQL Server from all misuse or malicious use of system resources. .NET code shares the advantage of compilation with extended stored procedures. .NET code is Just-In-Time compiled into machine instructions at execution time. .NET classes are objects to enable usage of object-oriented programming techniques. The execution engine controls storage allocation and memory management. This ensures that, short of a bug in the engine itself, .NET procedural code will never step on random memory buffers. In case of severe programmer error, the execution engine can always dispose of the offending thread or even an AppDomain without interfering while SQL Server continues to run without interruption. This is shown in Figure 1-2. Writing SQL Server procedural code is examined in detail in Chapters 3 and 4. SQL Server 2005 ships with an in-memory .NET data provider to optimize data access from managed procedural code. When using this provider, programmers have a choice of using .NET types or SQL types. Some .NET types, like System.Int32, require no conversion or marshaling, but some, such as System.Decimal, are not exact matches. The .NET classes in System.Data.SqlTypes correspond exactly to the corresponding SQL Server types. Using these types in .NET procedures means no type SQL Server Data Buffers Managed Code Stored Procedure Figure 1-2: Preventing Managed Code from Interfering with SQL Server Processing or Writing over Buffers

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services

INTRODUCTION srv_describe(pSrvProc, 1, Column 1 , SRV_NULLTERM, SRVVARCHAR, strlen(szText),

INTRODUCTION srv_describe(pSrvProc, 1, Column 1 , SRV_NULLTERM, SRVVARCHAR, strlen(szText), SRVVARCHAR, 0, NULL); // set column length and data srv_setcollen(pSrvProc, 1, strlen(szText)); srv_setcoldata(pSrvProc, 1, szText); // send row srv_sendrow(pSrvProc); // send done message srv_senddone(pSrvProc, (SRV_DONE_COUNT | SRV_DONE_MORE), 0, 1); return (XP_NOERROR); } SQL Server uses structured exception handling to wrap all calls to extended stored procedures. This prevents unhandled exceptions from damaging or shutting down SQL Server. There is, however, no way for SQL Server to prevent an extended stored procedure from misusing system resources. A rogue extended stored procedure could call the exit() function in the Windows runtime library and shut down SQL Server. Likewise, SQL Server cannot prevent a poorly coded extended stored procedure from writing over the memory SQL Server is using. This direct access to system resources is the reason that extended stored procedures are more efficient than T-SQL for non data access operations, but is also the reason that a stored procedure must undergo much more scrutiny before it is added to SQL Server. Under SQL Server 2005, T-SQL code continues to operate mostly as before. In addition to providing complete compatibility with existing code, this enables the millions of current T-SQL programmers to continue to write high-performance data access code for the SQL Server relational engine. For these programmers, T-SQL is still their language of choice. SQL Server 2005 adds the ability to write stored procedures, user- defined functions, and triggers in any .NET-compatible language. This enables .NET programmers to use their language of choice, such as C# or VB.NET, to write SQL Server procedural code. The .NET code that SQL Server runs is completely isolated from SQL Server itself. SQL Server uses a construct in .NET called an AppDomain. It completely isolates all resources that the .NET code uses from the resources that SQL Server uses, even though both SQL Server and the

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Tomcat Web Hosting services

.NET S EFFECTS ON SQL SERVER SQL statements, T-SQL

.NET S EFFECTS ON SQL SERVER SQL statements, T-SQL variables passed between T-SQL and the storage engine are not converted. Listing 1-1: A Simple Stored Procedure CREATE PROCEDURE find_expensive ( @category @price MONEY, @verdict VARCHAR(20) OUTPUT ) AS IF (SELECT AVG(cost) FROM PRODUCTS WHERE cat = @category) > @price SET @verdict = Expensive ELSE SET @verdict = GoodBuy Extended stored procedures are an alternative to interpreted T-SQL code and prior to SQL Server 2005 were the only alternative to T-SQL. Extended stored procedures written in a compiled language, such as C++, do numeric and string operations more efficiently than T-SQL. They also have access to system resources such as files, the Internet, and timers that T-SQL does not. Extended stored procedures integrate with SQL Server through the Open Data Services API. Writing extended stored procedures requires a detailed understanding of the underlying operating system that is not required when writing T-SQL. Typically, the reliability of an extended stored procedure is more suspect than that of T-SQL. In addition, data access operations by an extended stored procedure are not as efficient as T-SQL. Data accessed using ODBC or OLE DB requires data type conversion that T-SQL does not. An extended stored procedure that does data access also requires a connection to the database even though it runs inside of SQL Server itself. T-SQL directly accesses data in the storage engine and does not require a connection. Listing 1-2 shows a simple extended stored procedure written in C++. Listing 1-2: A Simple Extended Stored Procedure ULONG __GetXpVersion() { return ODS_VERSION; } SRVRETCODE xp_sayhello(SRV_PROC* pSrvProc) { char szText[15] = Hello World! ; // error handling elided for clarity // describe the output column

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services

INTRODUCTION Network Libraries/TDS Protocol Command Parser Optimizer Query

INTRODUCTION Network Libraries/TDS Protocol Command Parser Optimizer Query Execution Query Engine SQL Mgr Memory Mgr Expression Mgr Other OLE DB OLE DB and Non OLE DB Data Sources (Includes Other DBMS) Row and Index Access Transaction Mgr Lock Mgr Sort Mgr Storage Engine Buffer and Log Mgr Page Mgr File Mgr Utilities I/O Manager Win 32 API Figure 1-1: SQL Server Architecture, Version 7 and Above T-SQL code is highly integrated into SQL Server and uses data types that have the same representation in the storage engine as they do in T-SQL. Instances of these data types are passed between T-SQL and the storage engine without marshaling or conversion between representations. This makes T-SQL code as efficient in its use of type as the compiled code that runs in the storage engine. On the other hand, SQL Server interprets T-SQL code it does not compile it prior to use. This is not as efficient an execution technique as is used by the compiled code in the storage engine, but typically does not affect the performance of data access operations. It does affect, however, the performance of numeric and string-oriented operations. Prior to SQL Server version 7, T-SQL code was preparsed and precompiled into a tree format to alleviate some of this effect. Starting with SQL Server version 7, this is no longer done. An example of a simple T-SQL stored procedure is shown in Listing 1-1. Note that even though procedural code is interspersed with

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services

.NET S EFFECTS ON SQL SERVER different languages can

.NET S EFFECTS ON SQL SERVER different languages can completely interoperate if written to the Common Language Specification (CLS). Even though language features might be radically different as in Managed C++, where managed and unmanaged code can be mixed in the same program the feature sets are similar enough that an organization can choose the language that makes the most sense without losing features. In addition, .NET code can interoperate with existing COM code (via COM-callable wrappers and runtime-callable wrappers) and arbitrary Windows Dynamic Link Libraries (DLLs) through a mechanism known as Platform Invoke (PInvoke). So .NET with managed code is so compelling because it improves developer productivity and the reliability and security of applications, provides interoperability between a wide variety of languages, and supports use of legacy Windows code not written using .NET. .NET s Effects on SQL Server What does this mean with respect to SQL Server, Microsoft s flagship database management system (DBMS)? Originally, SQL Server shared a common ancestry with the Sybase database. SQL Server version 7 was split off from this common ancestry and rewritten using component-based programming. This makes adding new features at any level of functionality easier. Prior to version 7, SQL Server was a monolithic application. SQL Server version 7 factored code into layers, with communication between the relational and storage engines accessible through OLE DB. The SQL Server 7 component-based architecture is shown in Figure 1-1. In addition to easing accommodation of new features in future versions, such as SQL Server 2005, the new component-based model offered a variety of form factors, from the SQL Server Enterprise Edition, which provides a data store for an entire enterprise, to Microsoft Data Engine (MSDE), which provides a data store for a single application. Separation of the relational engine from the storage engine in SQL Server 7 made it easier to accommodate other data sources, such as Exchange or WebDav, which are traditionally not thought of as databases. SQL Server s relational engine can load OLE DB Rowsets from an Exchange or WebDav store just as though it were processing data managed by the storage engine. In versions of SQL Server prior to SQL Server 2005, there were two ways to write programs that ran in SQL Server: Transact-SQL (T-SQL) and extended stored procedures. T-SQL is Microsoft s proprietary implementation of Persistent Stored Modules (SQL-PSM) as defined in SQL standards.

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services

INTRODUCTION Managed code has made .NET so compelling.

INTRODUCTION Managed code has made .NET so compelling. Development tools produce managed code from .NET classes. Managed code is so named because it runs in an environment produced by mscoree.dll, the Microsoft common object runtime execution engine, which manages all facets of code execution. These include memory allocation and disposal, and class loading, which in traditional execution environments are a major source of programming errors. .NET also manages error recovery, and because it has complete information about the runtime environment, it need not always terminate an entire application in the face of an error such as an out-ofmemory condition, but can instead just terminate a part of an application without affecting the rest of it. .NET code makes use of code access security that applies a security policy based on the principal running the code, the code itself, and the location from which the code was loaded. The policy determines the permissions the code has. In .NET, by default, code that is loaded from the machine on which it runs is given full access to the machine. But code loaded from anywhere else, even if run by an administrator, is run in a sandbox that can access almost nothing on the machine. Prior to .NET, code run by an administrator would generally be given access to the entire machine regardless of its source. The application of policies is controlled by a system administrator and can be very fine grained. Multiple versions of .NET, based on different versions of user-written classes or different versions of the .NET base class libraries (BCL), can execute side by side on the same machine. This makes versioning and deployment of revised and fixed classes easier. The .NET kernel or execution engine and the base class libraries can be written to work with different hardware. A common .NET programming model is usable in x86-based 32-bit processors, like those that currently run versions of Windows 9x, Windows NT, Windows 2000, and Windows XP, as well as mobile computers like the iPaq running on radically different processors. The development libraries are independent of chipset. Because .NET classes can be Just-In-Time compiled (JIT compiled), optimization based on processor type can be deferred until runtime. This allows .NET to integrate more easily with the new versions of 64-bit processors. .NET tools compile code into an intermediate language (IL) that is the same regardless of the programming language used to author the program. Microsoft provides C#, Visual Basic .NET, Managed C++, JavaScript, and J#, a variant of the Java language that emits IL. Non-Microsoft languages such as COBOL.NET and Eiffel.NET are also first-class citizens. Code written in

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services

Sql server 2005 contains features that constitute the

Sql server 2005 contains features that constitute the biggest change since the internal server rewrite of SQL Server 7. This is true from both programmability and data model viewpoints. This chapter describes SQL Server 2005 in terms of .NET programmability, SQL:1999 compliance, user-defined types (UDTs), and XML integration to present a picture of holistic data storage, manipulation, and access. The .NET Runtime and the Microsoft Platform .NET is Microsoft s latest environment for running program code. The concept of managed code, running under control of an execution engine, has quickly permeated all major operating systems, including those from Microsoft. .NET is one of the core technologies in Windows Server 2003, Microsoft s latest collection of server platforms. Handheld devices and computer-based mobile phones have quickly acquired .NET-based development environments. .NET is an integral part of both Internet Information Server (IIS) and Internet Explorer (IE). ASP.NET runs on the Windows 2000 version and up of IIS 5.0; IE 5.5 and up can load and run .NET code referenced by tags embedded in Web pages. Rich .NET-based Windows applications, based on the WinForms library that comes with .NET, may be deployed directly from the Internet and run on Windows- based desktops. So what is it about .NET that has caused it to catch on?

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services