.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

Bookmark the permalink.

Comments are closed.