简体   繁体   English

在.NET中,如何知道重建索引是否成功?

[英]In .NET how to know if rebuild index was successful?

Below is the command. 下面是命令。
rowsRet = -1 rowsRet = -1

How can I know if the rebuild was successful? 我怎么知道重建是否成功?
If it does not throw an error can I assume it was successful? 如果没有抛出错误,我可以认为它是成功的吗?
This is in a try catch. 这是一个尝试。

sqlCmd.CommandText = "ALTER INDEX [IX_FTSwordDef_word] ON [dbo].[FTSwordDef] " + Environment.NewLine +
                        "REBUILD WITH (FILLFACTOR = 100, SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = ON);";
Debug.WriteLine(sqlCmd.CommandText);
int rowsRet = sqlCmd.ExecuteNonQuery();

You could try to see the last modified date of the index before and after your command to see if it changed. 您可以尝试在命令前后查看索引的最后修改日期,以查看索引是否已更改。

To check the last modified date of the index, you can refer to this 要检查索引的最后修改日期,你可以参考这个

SELECT STATS_DATE(OBJECT_ID('TABLENAMEHERE')
                 , (SELECT index_id FROM sys.indexes
                    WHERE name = 'INDEXNAMEHERE')
                 )

Let me know if that helps. 让我知道是否有帮助。 (I'm not sure, but I think you should get an error if the REBUILD fails) (我不确定,但是我认为如果REBUILD失败,您应该得到一个错误)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM