![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
SQL Server
iteye_21322
这个作者很懒,什么都没留下…
展开
-
SQL Server Row Count for All Tables
Option 1 SELECT sysobjects.Name, sysindexes.RowsFROM sysobjects INNER JOIN sysindexes ON sysobjects.id = sysindexes.idWHERE type = 'U' AND sysindexes.IndId < ...原创 2014-02-08 17:26:47 · 129 阅读 · 0 评论 -
Use CTE to Get List of Month
We can use CTE (common table expression) to get a list of month. ;WITH DateYear AS(SELECT 0 AS numUNION ALLSELECT num + 1 FROM DateYearWHERE num < 11)SELECT CONVERT(DATE,DATEADD(...原创 2014-04-18 14:25:32 · 75 阅读 · 0 评论 -
Delete Duplicated Row in SQL Server
1. Truncate NoDup table2. Create CTE1 to get the max MyTime group by FileName and MonthTRUNCATE TABLE NoDup;;WITH CTE1 AS(SELECT FileName, Max(MyTime) AS MaxMyTimeFROM SourceTableDupGROU...原创 2014-04-23 13:30:36 · 106 阅读 · 0 评论 -
SQL Server - Indexed Views
1. Create the view with 'SCHEMABINDING'CREATE VIEW [dbo].[vTest] WITH SCHEMABINDING ASSELECT 2. Create the indexCREATE UNIQUE CLUSTERED INDEX idx_vTest ON vTest(IndexColumn) 3. Constr...原创 2014-04-24 13:32:38 · 116 阅读 · 0 评论 -
SQL SERVER - AVG Time
SELECT DATEADD(SECOND,AVG(DATEDIFF(SECOND, 0, CAST(MyDateTimeColumn as TIME))), 0)FROM MyTable原创 2014-05-07 11:48:41 · 313 阅读 · 0 评论 -
SQL Server DMVs
扫盲: DMV = Dynamic Management Views,动态管理视图 Microsoft introduced a few more dynamic management views to also assist with identifying possible index candidates based on query history. The dynam...原创 2014-05-08 16:49:13 · 237 阅读 · 0 评论 -
Converting DateDiff to HH:MM:SS
Here is an example using backupset. If I understood what you were asking for this should be it. It outputs the data as datatype TIME. If you want datetime then replace CAST('00:00:00' AS TIME))...原创 2014-05-16 11:19:11 · 139 阅读 · 0 评论