是sqlserver 视图索引。具体工具 ,具体步骤,别复制网上的因为我看过了,实在不知道怎么创建。所以,请求大神帮忙看看。我这个工具不知到怎么创建。
写SQL语句,妥妥的。。。
use mlk;
GO
SET NUMERIC_ROUNDABORT OFF;
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT,
QUOTED_IDENTIFIER, ANSI_NULLS ON;
GO
--Create view with schemabinding.
IF OBJECT_ID ('dbo.mtlevel1', 'view') IS NOT NULL
DROP VIEW dbo.mtlevel1;
GO
CREATE VIEW dbo.mtlevel1
WITH SCHEMABINDING AS
SELECT
COUNT_BIG(1) AS TotalNumber,
Sum(dbo.TT_MT_LOG.MT_TOTAL) AS Demolition,
Sum(CASE dbo.TT_MT_LOG.MT_STATE WHEN '1' THEN 1 END) AS SendSuccess,
Sum(CASE dbo.TT_MT_LOG.MT_STATE WHEN '2' THEN 1 END) AS SendFailed,
Sum(CASE dbo.TT_MT_LOG.MT_STATE WHEN '3' THEN 1 END) AS ReceiveSuccess,
Sum(CASE dbo.TT_MT_LOG.MT_STATE WHEN '4' THEN 1 END) AS ReceiveFailed,
Sum(CASE dbo.TT_MT_LOG.MT_STATE WHEN '5' THEN 1 END) AS ReceiveNoState,
dbo.TT_MT_LOG.APP_PARAMETER1 AS BizCode,
CONVERT (CHAR (10),dbo.TT_MT_LOG.SEND_TIME,120) AS [DAY]
FROM
dbo.TT_MT_LOG
GROUP BY
dbo.TT_MT_LOG.APP_PARAMETER1,
CONVERT (CHAR (10),dbo.TT_MT_LOG.SEND_TIME,120)
GO
--Create an index on the view.
CREATE UNIQUE CLUSTERED INDEX IDX_V1 ON dbo.mtlevel1 (dbo.TT_MT_LOG.MT_LOG_ID);
GO
我这个创建哪里有问题啊,帮忙看一下
@狗霸人间: 你执行的时候,会提示你哪儿有问题呢。让我直接看,好头大的。