新聞中心
以下的文章主要向大家講述的是SQL Server 2005新功能的品味,SQL Server 2005數(shù)據(jù)庫相對于2000其在很多方面有很大的改進,有些在實際操作中還是非常實用的。舉幾個例子來簡單說明 這些例子我引用了PB2K庫。

創(chuàng)新互聯(lián),專注為中小企業(yè)提供官網(wǎng)建設、營銷型網(wǎng)站制作、成都響應式網(wǎng)站建設、展示型網(wǎng)站制作、成都網(wǎng)站制作等服務,幫助中小企業(yè)通過網(wǎng)站體現(xiàn)價值、有效益。幫助企業(yè)快速建站、解決網(wǎng)站建設與網(wǎng)站營銷推廣問題。
1. TOP 表達式
SQL Server 2000的TOP是個固定值,是不是覺得不爽,現(xiàn)在改進了。
前n名的訂單
- declare @n int
- set @n=10
- select top(@n) * from student
2. 分頁
不知各位過去用SQL Server 2000是怎么分頁的,大多都用到了臨時表。SQL Server 2005一句話就支持分頁,性能據(jù)說也非常不錯。
按age從小到大排序,求1到10行的結果
- select * from (select pid,sname,row_number() over(order by age) as row from student) as temp where row between 1 and 10
3. 排名
- select * from(select pid, title,score, RANK() OVER(order by score desc) as rank from material where score is not null) as temp where rank between 1 and 4
4. try ... catch
SQL Server 2000沒有異常,T-SQL必須逐行檢查錯誤代碼,對于習慣了try catch程序員,2005是不是更加親切:
SET XACT_ABORT ON -- 打開 try功能
- BEGIN TRY
- begin tran
- insert into student(sname,age) values('test',22)
- commit tran
- print 'commited'
- END TRY
- BEGIN CATCH
- rollback
- print 'rolled back'
- END CATCH
5. 通用表達式CTE
通過表達式可免除你過去創(chuàng)建臨時表的麻煩。
上述的相關內容就是對SQL Server 2005新功能的描述,希望會給你帶來一些幫助在此方面。
文章標題:SQLServer2005新功能有哪些?
轉載源于:http://m.fisionsoft.com.cn/article/cosjjdd.html


咨詢
建站咨詢
