惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
MongoDB | Blog
MongoDB | Blog
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence
D
Docker
云风的 BLOG
云风的 BLOG
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
G
Google Developers Blog
GbyAI
GbyAI
T
Tailwind CSS Blog
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
C
Check Point Blog
I
InfoQ
Microsoft Azure Blog
Microsoft Azure Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
阮一峰的网络日志
阮一峰的网络日志
小众软件
小众软件
N
Netflix TechBlog - Medium
B
Blog RSS Feed
腾讯CDC
aimingoo的专栏
aimingoo的专栏

博客园 - Scott Xu(南方小鬼)

C#发现之旅第一讲 C#-XML开发 XPath Operators Basic XPath Axes Basic XPath Syntax Basic XPath Basic XSLT Basic 深入浅出之正则表达式(二) 深入浅出之正则表达式(一) 通过Microsoft.Feeds获取feeds My Best Loves C#(3.0) 深入浅出系列之相关概念 C#(3.0) 深入浅出系列 Expression Studio 2.0 中文版发布了 一定能影响你的简单十句话 众说不一,“八零”后程序员到底怎么了? 你最应该雇佣的程序员的十个特征 多个检索页面,分析,Silverlight绘图 .net component 开发系列1(学习) C# 中的设计模式3:Abstract Factory(学习笔记)
SQL Server 2005 实用例子
Scott Xu(南方小鬼) · 2008-03-30 · via 博客园 - Scott Xu(南方小鬼)
  1. 获取最后插入的一条记录:scope_indentity()

    scope_indentity()  返回插入到同一作用域中(存储过程,.......)的indentity列内的最后一个indentity值

    declare @dt table
    ( _id 
    int identity(1,1),
      _name 
    char(10)
    )
    insert into @dt (_name) values('scottxu')
    insert into @dt (_name) values('psg')
    insert into @dt (_name) values('nanfangxiaogui')
    select * from @dt where _id=scope_identity() 

    结果:

    3    nanfangxiaogui


  2. 高性能分页:ROW_NUMBER()

    以下示例将返回行号为 5060(含)的行,并以 OrderDate 排序。

    USE AdventureWorks;
    GO
    WITH OrderedOrders AS
    (
    SELECT SalesOrderID, OrderDate,
    ROW_NUMBER() 
    OVER (order by OrderDate)as RowNumber
    FROM Sales.SalesOrderHeader ) 
    SELECT * 
    FROM OrderedOrders 
    WHERE RowNumber between 50 and 60;


  3. 高效获取记录数:sysindexes

    select rows from sysindexes where id = object_id('tablename'and indid in (0,1)