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. html-webpack-plugin 中使用 title选项设置模版中的值无效

    原文地址:https://segmentfault.com/q/1010000004555431 webpack.config.js配置: var webpack = require("we ...

  2. 对于glut和freeglut的一点比较和在VS2013上的配置问题

    先大概说一下glut.h和freeglut.h 首先要知道openGL是只提供绘图,不管窗口的,所以你需要给它一个绘图的区域(openGL能跨平台也与此有些关系) glut.h和freeglut.h都 ...

  3. the art of seo(chapter eleven)

    Tracking Results and Measuring Success goal -> driver ***Why Measuring Success Is Essential to th ...

  4. windows与Linux操作系统的差别

    用户需要记住:Linux和Windows在设计上就存在哲学性的区别.Windows操作系统 倾向于将更多的功能集成到操作系统内部,并将程序与内核相结合:而Linux不同 于Windows,它的内核空间 ...

  5. Linux中vsftpd安装和配置

    目录 Redhat/CentOS安装vsftp软件 Ubuntu/Debian安装vsftp软件 Redhat/CentOS安装vsftp软件 1. 安装vsftp $ yum install vsf ...

  6. POJ(有向图求LCA)

    Closest Common Ancestors Time Limit: 2000MS   Memory Limit: 10000K Total Submissions: 18013   Accept ...

  7. DBS:目录

    ylbtech-DBS:目录 1.返回顶部 1.   2. 2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返回顶部   7.返回顶部   8.返回顶部   9.返回顶 ...

  8. 获取CPU ID ,disk ID, MAC ID (windows ARM linux Mac)

    windows 命令行获取CPU ID,可以用ShellExecute wmic cpu get processorid ProcessorId BFEBFBFF000506E3 开源库: 查询CPU ...

  9. ceph应用情况分析

    1.概述 ceph是分布式的开源存储系统,同时支持块存储.对象存储和文件系统,ceph可以满足高性能.高可靠性和高扩展等特性. 目前ceph作为开源分布式存储已经被大量使用,尤其是在云环境下的应用,下 ...

  10. openStack高可用性和灾备方案

    1. 基础知识 1.1 高可用 (High Availability,简称 HA) 高可用性是指提供在本地系统单个组件故障情况下,能继续访问应用的能力,无论这个故障是业务流程.物理设施.IT软/硬件的 ...