select [all|distinct] [top (<expression>) [Percent] [with ties]] <column list> [from <source table(s)/views>] [where <restrictive condition>] [group by <column name or expression using a column in the select list>] [having &l…
INSERT [TOP (<expression>) [PERCENT] [INTO] <tabular object>[(column list)][OUTPUT <output clause>]{VALUES (<data values>) [,(<data values>)] [,...n]| <table source>| EXEC <procedure>| DEFAULT VALUES 这个结构看起来崩溃,更基本…
SELECT ManagerID AS Manager,COUNT(*) AS Reports FROM Human.Resources.Employee2 WHERE EmployeeID !=5 GROUP BY ManagerID HAVING COUNT(*)>3; having 是聚合以后算的,很棒.where 是聚合以前算的. 用FOR XML子句可以输出XML格式. ALL DISTINCT的用法.…
select Name,salesPersonID From Sales.store where name between 'g' and 'j' and salespersonID > 283 order by salespersonid,name desc/ASC 本语句的between的用法还是很有新意的,这个between是g开头和j开头之间的,不知道汉字会是什么情况? group by,经常配合min max sum avg,配合AS命名别名.group by配合聚合函数是常用的. c…
When you install SQL Server 2012 and you try to connect to SSIS services, you cannot due to that the SSIS service not running. When you manually try to start the SSIS service the service may fail due to login failure of the service account. By Defaul…
sql server 2012新特性, 支持 OFFSET/FETCH分页, 就像mysql的limit, 比之前的各种top舒服多了,  看各位大佬们的测评文章说效率也是不相上下的, 有时候写个小工具或者临时处理一些数据, 就不需要ef这种大工具出场了, 所以我临时拼了一个方法来用, 配合dapper还挺简单的. //假装using Dapper; public IEnumerable<Books> GetBooks(int pageIndex, int pageSize) { var co…
本数据源来自 https://www.kafan.cn/edu/922556.html  目的为了备忘 把原来的sql server 2005直接装成了2012,然后在建立链接服务器链接一台sql server 2000的服务器时,报错信息大概是“SQL Server Native Client 11.0 不支持链接SQL Server 2000 及更早版本”,但是在SQL Server2012中连接其他SQL Server数据库时可以使用以下代码: exec sp_addlinkedserve…
SQL Server 可以在实例,数据库,列,查询分别指定排序规则 /* Module 1 - working with Clollations */ -- 1.1 Obtain the Instance Collation from the GUI --Create a Database without specifying a specific Collation Create Database UnspecifiedCollationDB; GO -- Use the statement…
找到C:\ProgramData\Microsoft\SQL Server Management Studio\11.0\Addins路径,用notepad++打开RedGate.SIPFramework.AddIn. 会发现其中的Assembly节点是空的,手动加上就可以了 <?xml version="1.0" encoding="utf-8" standalone="no"?> <Extensibility xmlns=&…
CREATE <object type> <object name> CREATE DATABASE <database name> 比较完整的语法列表: 日志文件和数据库文件不要放在一块磁盘上,争抢磁盘IO,还有危害安全性. CREATE DATABASE <database name>[ON [PRIMARY] ([NAME = <'logical file name'>,] FILENAME = <'file name'> [,…