SQL Server 常用高级语法笔记】的更多相关文章

自从用了EF后很少写sql和存储过程了,今天需要写个比较复杂的报告,翻出了之前的笔记做参考,感觉这个笔记还是很有用的,因此发出来和园友分享. 1.case...end (具体的值)case后面有值,相当于c#中的switch case注意:case后必须有条件,并且when后面必须是值不能为条件. -----------------case--end---语法结构--------------------- select name , --注意逗号 case level --case后跟条件 wh…
1.字符串截取.字符串转数字 --Server.8.30 select SUBSTRING('SqlServer_2008',4,6) as DB, CONVERT(float,SUBSTRING('8.30~9.00',1,len('8.30~9.00')- CHARINDEX('~',REVERSE('8.30~9.00')))) as Time CONVERT(int,'字符串') 2.系统时间 select GETDATE() 系统时间 3.字符串拼接 方式一: --select @p_…
用于记录SQL SERVER常用语法,以及内置函数. 以下语句包含: WITH 临时表语法 ROW_NUMBER()内置函数,我一般主要是用来分页.针对于查出来的所有数据做一个数字排序 分页的BETWEEN   AND   我也主要是用于分页使用. WITH tab AS ( SELECT ROW_NUMBER() OVER ( ORDER BY CreateDate DESC ) AS RowNumber , DeptCode , DeptName , IsEnabled , IsType ,…
SQL Server T-SQL高级查询 高级查询在数据库中用得是最频繁的,也是应用最广泛的. Ø 基本常用查询 --select select * from student; //查询student表中所有字段.   --all 查询所有 select all sex from student;   --distinct 过滤重复 select distinct sex from student;   --count 统计 select count(*) from student; selec…
  系统存储过程 说明 sp_databases 列出服务上的所有数据库 sp_helpdb 报告有关指定数据库或所有数据库的信息 sp_renamedb 更改数据库的名称 sp_tables 返回当前环境下可查询的对象的列表 sp_columns 返回某个表列的信息 sp_help 返回某个表的所有信息 sp_helpconstraint 查看某个表的约束 sp_helpindex 查看某个表的索引 sp_stored_procedures 列出当前环境中的所有存储过程 sp_password…
阅读目录 一.SQL分类 二.基础语句 三.sql技巧 四.(MS SQL Server)SQL语句导入导出大全 回到目录 一.SQL分类 DDL—数据定义语言(CREATE,ALTER,DROP,DECLARE) DML—数据操纵语言(SELECT,DELETE,UPDATE,INSERT) DCL—数据控制语言(GRANT,REVOKE,COMMIT,ROLLBACK) 回到目录 二.基础语句 2.1.说明:创建数据库 create database db-name 2.2.说明:删除数据库…
DataSet的内容介绍,两种单例模式(并发量的考虑),SQL高级中的case语句.连接操作.子查询.派生表 -------------------------------- 1.Case的用法 使用方法一:(类似C#中的case的用法) ->语法: Case  表达式 when 值1 then 返回值 when 值2 then 返回值 - End ->案例:把用户表中数据,全部查询出来,要求把DelFlag=0的显示成未删除 select *,case DelFlag when 0 then…
高级查询在数据库中用得是最频繁的,也是应用最广泛的.   Ø 基本常用查询   --select select * from student; --all 查询所有 select all sex from student; --distinct 过滤重复 select distinct sex from student; --count 统计 select count(*) from student; select count(sex) from student; select count(di…
高级查询在数据库中用得是最频繁的,也是应用最广泛的. Ø 基本常用查询 --select select * from student;   --all 查询所有 select all sex from student;   --distinct 过滤重复 select distinct sex from student;   --count 统计 select count(*) from student; select count(sex) from student; select count(…
高级查询在数据库中用得是最频繁的,也是应用最广泛的. Ø 基本常用查询 --select select * from student;   --all 查询所有 select all sex from student;   --distinct 过滤重复 select distinct sex from student;   --count 统计 select count(*) from student; select count(sex) from student; select count(…