随笔分类 - SQL SERVER (MSSQL)
摘要:refer: https://techcommunity.microsoft.com/t5/azure-sql/monitor-cpu-usage-on-sql-server-and-azure-sql/ba-p/680777 https://www.cnblogs.com/lyhabc/archi
阅读全文
摘要:refer: https://blog.csdn.net/Hehuyi_In/article/details/89670462 https://docs.microsoft.com/en-us/sql/relational-databases/tables/temporal-tables?view=
阅读全文
摘要:refer: 看懂SqlServer查询计划 How do I identify slow queries in sql server? join operator, hash, merge, nested https://cloud.tencent.com/developer/article/10
阅读全文
摘要:refer : https://stackoverflow.com/questions/59283754/string-agg-with-line-break string agg char(10) 之后, copy paste 没效果,可以试试看这个, 另外有时候 copy paste 出来次序是
阅读全文
摘要:修订版请移驾到 SQL Server – Transaction & Isolation 事务与隔离 什么时候会用到嵌套事务 ? 为了代码复用,我们会写许多的储蓄过程,而中间如果需要使用到 transaction 难免就会发生嵌套了. sql server 并不直接支持嵌套事务. 但它可以用一些招式
阅读全文
摘要:1. select all table 2. select all column name from table 3. get column type 4. select table that have some column select t.TABLE_NAME from INFORMATION
阅读全文
摘要:更新: 2021-09-15 customer 1-n orders 想获取最新的 orders 可以使用 cross/outer apply 之前使用 with cte row number 来实现, 其实还有一个方式是用 cross apply cross apply 类似 inner join
阅读全文
摘要:更新: 2020-11-15 log file 是会一直长大的, 直到你 backup log file, backup full database log file 还是会长大. 一般的做法是 full back -> log backup (通常需要 2 次, 才可以 shrink, 不知道原因
阅读全文
摘要:1. computed column alter table tableName add columnName as (cast(aColumn as float) / bColumn * 100) persisted; 2. unique nullable create unique nonclu
阅读全文
摘要:从 sql 2012 开始, 微软为了让 insert 时 auto increment 快一些,做了一个 cache 的机制。 这个机制虽然好,但是也有麻烦的情况,如果你的 sql 突然 restart 了, 那么这个 cache 就流失了 这回导致你的 sql auto increment Id
阅读全文
摘要:SELECT @@VERSION refer : https://www.mssqltips.com/sqlservertip/1140/how-to-tell-what-sql-server-version-you-are-running/
阅读全文
摘要:refer : https://msdn.microsoft.com/en-us/library/ms189272.aspx simple 就不会有 log
阅读全文
摘要:使用 management studio right click database -> Tasks -> Generate Scripts -> next until "Set Scripting Options" -> Advance Types of data to script 选择 Sch
阅读全文
摘要:更新 : 2019-06-29 identity column 的局限是, 它只可以在一个 table 使用,而且它只能随着 insert 产生 另一个方法是用 SEQUENCE, sql server 2012 的功能 https://docs.microsoft.com/en-us/sql/t-
阅读全文
摘要:更新: ef core issue https://github.com/aspnet/EntityFrameworkCore/issues/4073 这种情况可以 cascade delete and update 这两种都算 parent child 不可以 cascade delete and
阅读全文
摘要:2019-08-11 sum decimal 除法 如果拿 2 个 decimal sum 了相除,经常会丢失小数点. 结果是 0.39252202 0.392522 所以要做记得 convert 去 decimal 哦, 还有一些奇葩的东西可以参考下面这个。也是关于丢失 digits 的 http
阅读全文
摘要:更新: 2021-05-13 convert int to am pm https://stackoverflow.com/questions/38329899/convert-integer-value-into-hour-value-am-pm-in-sql-server/38330108#38
阅读全文
摘要:refer : http://www.codeproject.com/Articles/25600/Triggers-SQL-ServerSELECT * FROM sys.triggers; //get allSELECT OBJECT_DEFINITION (OBJECT_ID(N'onJobP...
阅读全文
摘要:参考 :http://cnn237111.blog.51cto.com/2359144/1226911http://www.cnblogs.com/huey/p/4518979.html我们经常会使用到树形结构,比如做产品分类,国家和州,等等等那么用关系数据库来实现树形的方式也有很多,各有好坏(我最...
阅读全文
摘要:inner join compare 的时候 Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Chinese_PRC_CI_AS" in the equal to operation
阅读全文