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

实现sqlserver分页查询语句

 sqlServer:
一次查询,数据库只返回一页的数据。而不是取出所有的数据。
pagesize: 每页显示记录数
cureentpage:当前页数
select * from (   select TOP pagesize * from ( SELECT TOP pagesize*cureentpage   * from my_table   ORDER BY id ASC ) as amyTable   ORDER BY id DESC ) as bmyTable   ORDER BY id ASC
假设共有有8条记录,每页显示3条记录,id 为3,6,7,37
 第一页(首页)
select * from (   select TOP 3  * from ( SELECT TOP 3*1   * from my_table   ORDER BY id ASC ) as amyTable   ORDER BY id DESC ) as bmyTable   ORDER BY id ASC
 第二页
select * from (   select TOP 3  * from ( SELECT TOP 3*2  * from my_table   ORDER BY id ASC ) as amyTable   ORDER BY id DESC ) as bmyTable   ORDER BY id ASC     
第三页(尾页)
select * from (   select TOP 8-2*3  * from ( SELECT TOP 8-3*2  * from my_table   ORDER BY id ASC ) as amyTable   ORDER BY id DESC ) as bmyTable   ORDER BY id ASC     


相关文档:

SQLServer日期格式代码

转换方法: convert(nvarchar(8),starttime,14)
    100   (1,   2)  
    默认设置  
    mon   dd   yyyy   hh:miAM(或   PM)     
    
    101  
&nbs ......

sqlserver 存储过程例子

 什么是存储过程呢?
  定义:
  将常用的或很复杂的工作,预先用SQL语句写好并用一个指定的名称存储起来, 那么以后要叫数据库提供与已定义好的存储过程的功能相同的服务时,只需调用execute,即可自动完成命令。
  讲到这里,可能有人要问:这么说存储过程就是一堆SQL语句而已啊?
  Microsoft公司为什么还 ......

sqlserver 视图

/*drop table scourse
drop table course
drop table student
drop table major*/
create database db
use db
--专业表
create table major
(spno char(5) not null primary key,
 spname varchar(20) not null,
 pno char(2) )
--学生表
create table student
(sno char(7) not null primary key, ......

SQLServer 2005 常用的函数

字符串函数:
● ASCII('a')=97---返回字母a对应的ASCII码
● CHAR('48')=0---返回48这个ASCII码对应的字符
● LCASE('ABcdE')="abced" 或 LOWER('ABcdE')="abced"(将给定字符串转为小写)
● UCASE('ABcdE')="ABCDE" 或 UPPER('ABcdE')="ABCDE"(将给定字符串转为大写)
● LTRIM('  fgf gh  ')="fgf ......

SQLSERVER 添加一个不可为空的字段

SqlServer 表中当之前有记录的时候发现表设计的不合理要加字段,
但是alter table Skating_Consumption add MemberCardId numeric(9)只能加可为空的字段,
解决办法,
第一、加个为空的字段
第二、更新表中记录这个字段为某个值
第三、再更改表字段为非空
语句
alter table Skating_Consumption add MemberCardId nu ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号