Server SQL Server 2005 is very much improved relative to SQL Server 2000, and some of it is very practical. Let me give you a few examples to illustrate these examples I quote the Northwind Library.
1. Top expression
The top of SQL Server 2000 is a fixed value, does not feel good, now improved.
--Order of top N names
DECLARE @n int
Set @n = 10
Select Top (@n) * from Orders
2. Paging
I do not know how you used to use SQL Server 2000 paging, most of the use of temporary tables. SQL Server 20,051 words support paging, and performance is said to be very good.
--by freight from small to large order, 20 to 30 of the results of the line
SELECT * FROM (select OrderId, Freight, Row_number () over (order by Freight) as ROW from Orders) a
where row between 30
3. Ranking
SELECT * FROM (select OrderId, Freight, Rank () over (order by Freight) as rank from Orders) a
where rank between 30
4. Try ... catch
SQL Server 2000 has no exceptions, T-SQL must check the error code line-by-row, and 2005 is not kinder to the accustomed Try Catch programmer:
SET Xact_abort on--Open try function
BEGIN TRY
BEGIN Tran
Insert into Orders (CUSTOMERID) VALUES (-1)
Commit Tran
print ' commited '
End TRY
BEGIN CATCH
Rollback
print ' Rolled back '
End CATCH
5. Common expression CTE
An expression eliminates the hassle of creating a temporary table in the past.
--Example: paging with a common expression
With Orderfreight as (
Select OrderId, Freight, Row_number () over (order by Freight) as ROW from Orders
)
Select OrderId, Freight from Orderfreight where row between 20
In particular, recursion is supported by an expression.
6. Publish Web Service directly
If you want to turn the store procedure into a Web service, use this. NET, IIS does not need to, through the Windows 2003 HTTP Protocol stack directly release WebService, with this feature requires Windows 2003 SP1
Wsdl=default,
Database= ' Northwind ',
Namespace= ' http://mysite.org/'
)
The Web service is released, typing http://localhost/sql/orders?wsdl to get the WSDL
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.