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

SQL语句汇总

SQL :Structured Query Language结构化查询语言
1.Select [Predicate] *(filed) from table/view Where ... Group by ... Having... Order by ... With ...
   Predicate:包括all/Distinct/Distinctrow/Top,限制查询结果;
   As可以命名别名;
   Where ... 指定某些条件,将所有符合条件的记录过滤出来,下面是SQL提供的运算符和关键字。
   算术运算符:+、-、*、/、%
   比较运算符:=、<、>、>=、<=、<>
   字符串操作比较符:like、 not like
   逻辑操作符:and、or、not
   值的域:Between、not between
   值的列表:in,not in
   未知的值:is null、is not null
   Group by ... 多和聚合函数一起使用,sum、avg、count、max、min、first、last。
   Having... 组或聚合函数的条件判断
2.高级查询
   Union合并多个结果集。
   Inner join内联接查询。
   Outer join外联接查询。(Left/Right Outer join)
   Trasform交叉表查询。
   例:Trasform sum(销量) as 销量 select 语言类型 from 图书销售 group by 语言类别 pivot 销售时间
   Case静态交叉表。(Case ... When ... Then ..else null end) as [...]
   用存储过程实现动态交叉表。
3.其他
   格式化函数Format(参数,格式) ---不支持SQL server
   字符串函数:Mid、Len
   日期函数:DateDiff
   


相关文档:

ASP.NET连接SQL和ACCESS的方法

SQL:
using System.Data.SqlClient;
string sql = "server=.;uid=sa;pwd=;database=tablename;";
ACCESS:
using System.Data.OleDb;
string sql = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" + HttpRuntime.AppDomainAppPath + "//App_Data//db.mdb";
HttpRuntime.AppDomainAppPath 为根目录
......

如何用SQL语言选择表中的第二条第三条第N条记录

如何用SQL语言选择表中的第二条第三条第N条记录
--ID为唯一性就行了
select top 1 * from table
where ID not in(select top 1 ID from table)--第2条
select top 1 * from table
where ID not in(select top 2 ID from table)--第3条
......

Auto process Cube with SQL Agent job

(1)     Connect to the Analysis server, select the database which we want it to be automatically processed. Right click on this database, choose ‘Process’:
(2)     In the opening ‘Process database’ form, click the ‘Script Action ......

SQL Server 索引结构及其使用(二)

改善SQL语句
  很多人不知道SQL语句在sql server中是如何执行的,他们担心自己所写的SQL语句会被SQL SERVER误解。比如:
select * from table1 where name=''zhangsan'' and tID > 10000
和执行:
select * from table1 where tID > 10000 and name=''zhangsan''
  一些人不知道以上两条语句的执行效率是否一 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号