首页 新闻 会员 周边 捐助

哪一种 Navicat for SQL Server工具能创建索引

0
悬赏园豆:30 [已解决问题] 解决于 2015-10-22 09:39

是sqlserver 视图索引。具体工具 ,具体步骤,别复制网上的因为我看过了,实在不知道怎么创建。所以,请求大神帮忙看看。我这个工具不知到怎么创建。

狗霸人间的主页 狗霸人间 | 初学一级 | 园豆:4
提问于:2015-10-21 13:37
< >
分享
最佳答案
0

写SQL语句,妥妥的。。。

收获园豆:30
幻天芒 | 高人七级 |园豆:37205 | 2015-10-21 13:50

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
我这个创建哪里有问题啊,帮忙看一下

狗霸人间 | 园豆:4 (初学一级) | 2015-10-21 14:15

@狗霸人间: 你执行的时候,会提示你哪儿有问题呢。让我直接看,好头大的。

幻天芒 | 园豆:37205 (高人七级) | 2015-10-21 16:16
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册