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. 使用python转换编码格式

    之前有写过一个使用powershell转换文档格式的方法,然而因为powershell支持不是很全,所以并不好用.这里使用python再做一个. 思路 检测源码格式,如果不是utf8,则进行转换,否则 ...

  2. URAL - 1297 Palindrome —— 后缀数组 最长回文子串

    题目链接:https://vjudge.net/problem/URAL-1297 1297. Palindrome Time limit: 1.0 secondMemory limit: 64 MB ...

  3. PYTHON 爬虫笔记十:利用selenium+PyQuery实现淘宝美食数据搜集并保存至MongeDB(实战项目三)

    利用selenium+PyQuery实现淘宝美食数据搜集并保存至MongeDB 目标站点分析 淘宝页面信息很复杂的,含有各种请求参数和加密参数,如果直接请求或者分析Ajax请求的话会很繁琐.所以我们可 ...

  4. C/C++连接查询MYSQL

    1. [代码][C/C++]代码 #include <mysql/mysql.h>#include <stdio.h>#include <string.h>int ...

  5. legend2---开发日志14(游戏对用户友好的设计思路)

    legend2---开发日志14(游戏对用户友好的设计思路) 一.总结 一句话总结: 不强制,但是激励:比如宗门灵力等级从强制提升到提升宗门和用户的修炼速度 1.丹药有必要做成随机数值么? 没有 1. ...

  6. html5--1.7超链接上

    html5--1.7超链接上 一.超链接的5种形式 <!DOCTYPE html> <html lang="en"> <head> <me ...

  7. Multiple webcams on ZoneMinder

    Monitoring a 3D Printer I have tidied my new workshop and I am starting to play with 3d-printing aga ...

  8. The Review Plan I-禁位排列和容斥原理

    The Review Plan I Time Limit: 5000ms Case Time Limit: 5000ms Memory Limit: 65536KB   64-bit integer ...

  9. POJ2387(最短路入门)

    Til the Cows Come Home Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 38556   Accepted ...

  10. Ubuntu ssh免密登录

    ssh免密登录工作原理 server A免登录到server B: 1.在A上生成公钥私钥. 2.将公钥拷贝给server B,要重命名成authorized_keys(从英文名就知道含义了) 3.S ...