SQL SERVER Study

Source: Internet
Author: User
Tags one table management studio

1. SQL SERVER Install
Free to try theDays. The latest is version 2014. 2. Attach, Detach can add or remove existing database files. The format of the database file is:. mdfSuffix 3. The E-r diagram can be established on the client. Primary note is the primary foreign key relationship, and the foreign key of one table is the primary key of the other table . 4. T-SQL StudyEG1:order by No.Example: Select ProductID, Name, Productnumber,color, Size, ListPrice from Production.Product o Rder by 2 Description: Here's 2, which means to sort by "Name".Sort by the number of column after select.  EG2:IsNull function: Determine whether the simulation of a data is empty.
For example: Select ProductID, Name, ProductNumber,IsNull(Color, "),IsNull(Size, '), ListPrice
From Production.Product ORDER by 2 Eg3:As keyword: alias the table column.
Example: Select ProductID, Name, ProductNumber, IsNull (Color, ") asColor, IsNull (Size, ') asSize, ListPrice
From Production.Product ORDER by 2 EG4:wildcard: Wildcard charactersExample: SELECT * from Production.Product where nameLike '%mountain% '----Wildcard% matches any zero or more characters SELECT * FROM Production.Product
where nameLike ' _ountain% 'EG5:In ; not inExample: SELECT * from production.product where sizeinch(' 20 ', ' 50 ', ' 55 ')  SELECT * FROM production.product where size not in(' 20 ', ' 50 ', ' 55 ') Eg6:is null; is not NULLExample: SELECT * from production.product where sizeis null  SELECT * FROM production.product where sizeis not null Eg6:and ; orExample: SELECT * from production.product where color = ' red ' andcolor = ' Black ' SELECT * from production.product where color = ' red 'orcolor = ' Black ' 5. Aggregation FunctionsEG1:count; distinctFor example: SELECTCount(SalesPersonID)
from [Sales]. [SalesOrderHeader] where SalesPersonID is not null Selectdistinct(SalesPersonID) from [Sales]. [SalesOrderHeader] where SalesPersonID is not NULL selectCount(distinct(SalesPersonID)) from [Sales]. [SalesOrderHeader] where SalesPersonID is not NULL EG2:AVG, Min, Max,sumFor example: SELECTAVG(SalesPersonID) as Averagetotalsales,Min(SalesPersonID) as Minimumtotalsales,Max(SalesPersonID) as Maximumtotalsales,Sum(SalesPersonID) as summarytotalsales from [Sales]. [SalesOrderHeader] Eg3:The classical T-SQL query!!!For example: Select SalesPersonID, OrderDate,Max(TotalDue) as maximumtotalsales from [Sales]. [SalesOrderHeader] where SalesPersonID is isn't null and OrderDate > ' 2016/1/1 ' GROUP by Sa Lespersonid, OrderDate hasMax(TotalDue) > 150000 ORDER BY SalesPersonID Desc 6. TipsEG1:How do i show line number?Solution: In the top row of the SS Management Studio Ribbon, find the Tool--and Options EG2:How to convert queries casing freely? Solution: In the top row of the SS Management Studio Ribbon, find Edit----------and--uppercase/lowercase

SQL SERVER Study

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.