SQl 命令

select count(*) from Report;   

sql server中不支持limit操作,但是可以用top;如下:

  1. select id from tablename  
 如果要查询上述结果中前6条记录,则相应的SQL语句是:
[sql] view plaincopy
 
  1. select top 6 id from tablename   
如果要查询上述结果中第 7 条到第 9 条记录,则相应的SQL语句是:
[sql] view plaincopy
 
  1. select top 3 id from tablename  
  2. where id not in (  
  3.   select top 6 id from tablename  
  4. )  
[sql] view plaincopy
 
  1. select top (n-m+1) id from tablename  
  2. where id not in (  
  3.   select top m-1 id from tablename  
  4. )  
[sql] view plaincopy
 
  1. select top @pageSize id from tablename  
  2. where id not in (  
  3.   select top @offset id from tablename  
(1) 数据记录筛选:
  sql="select * from 数据表 where 字段名=字段值 order by 字段名 [desc]"
  sql="select * from 数据表 where 字段名 like '%字段值%' order by 字段名 [desc]"
  sql="select top 10 * from 数据表 where 字段名=字段值 order by 字段名 [desc]"
  sql="select top 10 * from 数据表 order by 字段名 [desc]"
  sql="select * from 数据表 where 字段名 in ('值1','值2','值3')"
  sql="select * from 数据表 where 字段名 between 值1 and 值2"
  (2) 更新数据记录:
  sql="update 数据表 set 字段名=字段值 where 条件表达式"
  sql="update 数据表 set 字段1=值1,字段2=值2 …… 字段n=值n where 条件表达式"
  (3) 删除数据记录:
  sql="delete from 数据表 where 条件表达式"
  sql="delete from 数据表" (将数据表所有记录删除)
  (4) 添加数据记录:
  sql="insert into 数据表 (字段1,字段2,字段3 …) values (值1,值2,值3 …)"
  sql="insert into 目标数据表 select * from 源数据表" (把源数据表的记录添加到目标数据表)

 

SQL Server 2008语句大全完整版

http://blog.csdn.net/luowei505050/article/details/6451084

原文地址:https://www.cnblogs.com/manmanlu/p/3412119.html