易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL 取n到m条记录

1.
select   top   m   *   from   tablename   where   id   not   in   (select   top   n   id   from   tablename)
2.
select   top   m   *   into   临时表(或表变量)   from   tablename   order   by   columnname   --   将top   m笔插入
set   rowcount   n
select   *   from   表变量   order   by   columnname   desc
3.
select   top   n   *   from  
(select   top   m   *   from   tablename   order   by   columnname)   a
order   by   columnname   desc
4.如果tablename里没有其他identity列,那么:
select   identity(int)   id0,*   into   #temp   from   tablename
取n到m条的语句为:
select   *   from   #temp   where   id0   >=n   and   id0   <=   m
如果你在执行select   identity(int)   id0,*   into   #temp   from   tablename这条语句的时候报错,那是因为你的DB中间的select   into/bulkcopy属性没有打开要先执行:
exec   sp_dboption   你的DB名字, "select   into/bulkcopy ",true
5.如果表里有identity属性,那么简单:
select   *   from   tablename   where   identitycol   between   n   and   m  
比如一个表有100条记录怎么取其中的第30至第40条记录??
select &nbs


相关文档:

C#打包SQL数据库部署安装


参考《ASP.NET与SQL一起打包部署安装》
,这篇文章是针对VB.NET与SQL 一起打包的,但是我使用的是C#,当然只要修改一下主要安装类库就行了!C#的类库代码如下:DBCustomAction.cs
using System;
using System.Collections;
using System.Data.SqlClient;
using System.ComponentModel;
using System.Configuration.Inst ......

SQL分页方法

表中主键必须为标识列,[ID] int IDENTITY (1,1)
也可以使用联合主键 id+id2+id3+……
 
1.分页方案一:(利用Not In和SELECT TOP分页)
语句形式:  
SELECT TOP 10 *
from TestTable
WHERE (ID NOT IN
          (SELECT TOP 20 id
&nb ......

Linq to SQL Like Operator(转载)


As a response for customer's question, I decided to write about using Like Operator in Linq to SQL queries.
Starting from a simple query from Northwind Database;
var query = from c in ctx.Customers
            where c.City == "London"
&nbs ......

SQL Server 中的查询通知 (ADO.NET)

查询通知是在 Microsoft SQL Server 2005 中以及 ADO.NET 2.0 的 System.Data.SqlClient 命名空间中引入的。查询通知建立在 Service Broker 基础结构的基础上,使应用程序可以在数据更改时收到通知。如果应用程序提供数据库中信息的缓存(例如 Web 应用程序),需要在源数据更改时接收通知,此功能特别有用。
通过三种方式 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号