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

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
Hugging Face - Blog
Hugging Face - Blog
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
L
LangChain Blog
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
GbyAI
GbyAI
MyScale Blog
MyScale Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
U
Unit 42
Martin Fowler
Martin Fowler
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
博客园 - 聂微东
大猫的无限游戏
大猫的无限游戏
M
MIT News - Artificial intelligence
A
About on SuperTechFans
Stack Overflow Blog
Stack Overflow Blog
V
V2EX

博客园 - 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)