1. SQL SERVER Install
    可以免费试用天。最新的是2014版本。
 
2. Attach, Detach 可以添加或去掉已有的数据库文件。
    数据库文件的格式是: .mdf 后缀
 
3. 客户端上可以建立 E-R图。主要注意主外键关系,一个表的外键是另一个表的主键。
 
4. T-SQL Study
    eg1: order by no.
    例如: select ProductID, Name, ProductNumber,Color, Size, ListPrice
                 from Production.Product
                 order by 2
    说明: 这里的2,就是说按“Name” 进行排序。按Select后的 第几个column进行排序。
 
    eg2: IsNull 函数: 判断模拟一数据是否为空。
    例如: select ProductID, Name, ProductNumber, IsNull(Color, ''), IsNull(Size, ''), ListPrice
                 from Production.Product
                 order by 2
    
    eg3: as 关键字:给表列取别名。
    例如: select ProductID, Name, ProductNumber, IsNull(Color, '') as Color, IsNull(Size, '') as Size, ListPrice
                 from Production.Product
                 order by 2
 
     eg4: wildcard: 通配符
    例如: select *  from Production.Product
                 where name like '%Mountain%'      ----Wildcard % matches any zero or more characters
 
                 select *  from Production.Product
                 where name like '_ountain%'            
 
    eg5: in   ;  not in
    例如: select *  from Production.Product
                 where size in ('20', '50','55')     
 
                select *  from Production.Product
                 where size not in ('20', '50','55')        
 
    eg6: is null   ;  is not null
    例如: select *  from Production.Product
                 where size is null     
 
                select *  from Production.Product
                 where size is not null        
 
     eg6: and   ;  or
    例如: select *  from Production.Product
                 where color = 'red' and color = 'black'
 
                select *  from Production.Product
                 where color = 'red' or color = 'black'  
 
5. 聚合函数
    eg1: count ; distinct
    例如: select count(SalesPersonID)
                from [Sales].[SalesOrderHeader]
                 where SalesPersonID is not null
 
                select distinct(SalesPersonID)
                from [Sales].[SalesOrderHeader]
                 where SalesPersonID is not null
 
                select count(distinct(SalesPersonID))
                from [Sales].[SalesOrderHeader]
                 where SalesPersonID is not null
    
    eg2: Avg, Min, Max,Sum
    例如: select 
                Avg(SalesPersonID) as AverageTotalSales
                , Min(SalesPersonID) as MinimumTotalSales
                , Max(SalesPersonID) as MaximumTotalSales
                , Sum(SalesPersonID) as SummaryTotalSales
                from [Sales].[SalesOrderHeader]
 
    eg3: The classical T-SQL query !!!
    例如: select SalesPersonID, OrderDate, Max(TotalDue) as MaximumTotalSales
                from [Sales].[SalesOrderHeader]
                where SalesPersonID is not null and OrderDate > '2016/1/1'
                group by SalesPersonID, OrderDate
                having Max(TotalDue) > 150000
                order by SalesPersonID desc
 
6. 小技巧
    eg1: 如何显示Line Number?
    解决方案: 在SS Management Studio 最上面一行 ribbon 里面找到 Tool --> Options
 
    eg2: 如何自由转换 queries 大小写?
    解决方案: 在SS Management Studio 最上面一行 ribbon 里面找到 Edit --> Advanced  --> Make UpperCase / LowerCase
  使用快捷键:
  Ctrl + Shift + U  转换为大写
  Ctrl + Shift + L  转换为小写

SQL SERVER Study的更多相关文章

  1. 看完SQL Server 2014 Q/A答疑集锦:想不升级都难!

    看完SQL Server 2014 Q/A答疑集锦:想不升级都难! 转载自:http://mp.weixin.qq.com/s/5rZCgnMKmJqeC7hbe4CZ_g 本期嘉宾为微软技术中心技术 ...

  2. SQL Server 执行计划缓存

    标签:SQL SERVER/MSSQL SERVER/数据库/DBA/内存池/缓冲区 概述 了解执行计划对数据库性能分析很重要,其中涉及到了语句性能分析与存储,这也是写这篇文章的目的,在了解执行计划之 ...

  3. SQL Server 编程入门经典(3)之T-SQL基本语句

    本章内容简介: 如何从数据库检索数据(SELECT) 如何向表中插入数据(INSERT) 如何适当更新数据(UPDATE) 如何删除表中数据(DELETE) 3.1 基本SELECT语句  如果你在此 ...

  4. SQL Server 性能优化实战系列(二)

    SQL Server datetime数据类型设计.优化误区 一.场景 在SQL Server 2005中,有一个表TestDatetime,其中Dates这个字段的数据类型是datetime,如果你 ...

  5. SQL Server跨服务器查询的实现方法,OpenDataSource

    SQL Server跨服务器查询的方法我们经常需要用到,下面就为您介绍两种SQL Server跨服务器查询的方法,如果您感兴趣的话,不妨一看. SQL Server跨服务器查询方法一:用OPENDAT ...

  6. C#:连接本地SQL Server语句

    一.Windows身份验证方式 SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Data Source ...

  7. SQL Server technical bulletin - How to resolve a deadlock

    https://support.microsoft.com/en-us/help/832524/sql-server-technical-bulletin-how-to-resolve-a-deadl ...

  8. 最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目

    最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目 最近一个来自重庆的客户找到走起君,客户的业务是做移动互联网支付,是微信支付收单渠道合作伙伴,数据库里存储的是支付流水和交易流水 ...

  9. SQL Server 大数据搬迁之文件组备份还原实战

    一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 解决方案(Solution) 搬迁步骤(Procedure) 搬迁脚本(SQL Codes) ...

随机推荐

  1. Linux_学习_02_ 重启tomcat与查看tomcat日志

    一.重启tomcat服务器 cd /home/ehlhec/tomcat_dingtalk/bin ./shutdown.sh ps -ef|grep java ./startup.sh (1) 进入 ...

  2. springAOP原理以及概念

    需求:1.拦截所有业务方法2.判断用户是否有权限,有权限就让他执行业务方法,没有权限就不允许执行.(是否有权限是根据user是否为null作为判断依据) 思考: 我们该如何实现? 思路1: 我们在每个 ...

  3. Virtual Codeforces Round #392 (Div. 2)

    下午闲来无事开了一场Virtual participation 2h就过了3道水题...又跪了..这只是Div. 2啊!!! 感觉这次直接就是跪在了读题上,T1,T2读题太慢,T3还把题读错了 要是让 ...

  4. Python中定时任务框架APScheduler的快速入门指南

    前言 大家应该都知道在编程语言中,定时任务是常用的一种调度形式,在Python中也涌现了非常多的调度模块,本文将简要介绍APScheduler的基本使用方法. 一.APScheduler介绍 APSc ...

  5. POJ3580:SuperMemo

    浅谈\(splay\):https://www.cnblogs.com/AKMer/p/9979592.html 浅谈\(fhq\)_\(treap\):https://www.cnblogs.com ...

  6. WPF GridView中的CellTemplate失效的原因

    最近做一个ListView的Style时,发现一个问题, 就是我的GridView的GridViewColumn的CellTemplate无论是用StaticResource还是DynamicReso ...

  7. jquery/原生js/css3 实现瀑布流以及下拉底部加载

    思路: style: <style type="text/css"> body,html{ margin:; padding:; } #container{ posit ...

  8. shell里的` ` $( ) ${ } expr $(( ))

    转自:http://blog.sina.com.cn/s/blog_6151984a0100ekz2.html 所有UNIX命令,要取结果或输出,都要用$( )或反引号` ` tt=` file te ...

  9. Autofac依赖注入框架使用

    简介: Autofac是一款IOC框架,比较于其他的IOC框架,如Spring.NET,Unity,Castle等等所包含的,它很轻量级性能上非常高 控制反转和依赖注入: 控制反转 IOC(Inver ...

  10. 2013-2014回首&展望

    2013年,可以说是此前18年中,最重要最感触的一年了. 和老婆相爱,考高考,入大学等等事情全都在这美妙的一年里发生了. 2013: 开心:·和老婆相爱,共同经历了大大小小的风雨·每天都有期待的东西· ...