![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Sql Server
_平凡的自我_
Life is an onion and one cries while peeling it.
展开
-
sql server 执行效率分析
SELECT TOP 50 execution_count [执行次数] , total_elapsed_time / 1000 [总耗时(ms)] , ( total_elapsed_time / execution_count ) / 1000 [平均耗时(ms)] , total_worker_time / 1000 [总消耗C...原创 2020-03-23 14:00:24 · 608 阅读 · 0 评论 -
数据库创建连续日期表
IF EXISTS(SELECT * FROM sysobjects WHERE name = 'Weaver_System_Date') DROP TABLE Weaver_System_DateGOCREATE TABLE Weaver_System_Date( id INT IDENTITY(1,1) PRIMARY KEY, system原创 2016-01-07 11:55:59 · 721 阅读 · 0 评论 -
sql收藏
查询sql索引SELECT 索引名称 = a.name , 表名 = c.name , 索引字段名 = d.name , 索引字段位置 = d.colidFROM sysindexes a JOIN sysindexkeys b ON a.id = b.id原创 2016-01-07 11:56:25 · 251 阅读 · 0 评论 -
sysobjects 中type含义
sysobjects 中type含义C = CHECK 约束 D = 默认值或 DEFAULT 约束F = FOREIGN KEY 约束 FN = 标量函数IF = 内嵌表函数K = PRIMARY KEY 或 UNIQUE 约束 L = 日志P = 存储过程R = 规则RF = 复制筛选存储过程S = 系统表 TF = 表函数TR =转载 2015-12-08 13:41:05 · 669 阅读 · 0 评论 -
sqlserver通过游标循环查询
DECLARE @id INT;DECLARE tempCursor CURSORFOR ( SELECT id FROM HrmResource WHERE status IN ( 0, 1, 2, 3 ) ) ORDER BY id; --创建游标tempCursor,并定义游标所指向的集合 OPE原创 2018-01-12 14:17:14 · 4339 阅读 · 0 评论 -
sql server删除重复数据
DELETE aWHERE id NOT IN ( SELECT MIN(id) FROM a GROUP BY col1, col2 ) 可以简单理解为用重复字段col1,col2(不能分组的字段需要转换下)进行分组,取id最小的,删除表里id不在这个查询里的,即为删除重复数据...原创 2018-03-20 11:49:14 · 298 阅读 · 0 评论 -
sql将一列转为一行
select stuff((select ';'+name from Student for xml path('')),1,1,'') as name原创 2018-11-23 14:27:41 · 1233 阅读 · 0 评论 -
SQL去除非数字
CREATE FUNCTION replace_notnum ( @name VARCHAR(50) )RETURNS VARCHAR(50)AS BEGIN WHILE PATINDEX('%[^0-9]%', @name) > 0 SET @name = STUFF(@name, PATINDEX('%[^0-9]%', @name)...原创 2018-12-19 13:27:02 · 3402 阅读 · 0 评论