I'm trying to drop an index created on a table, but I get this error -
The operation 'ALTER TABLE DROP INDEX' is supported only with memory optimized tables.
I need to remove this index in order to drop a field in my table. Is there any way of doing this without duplicating the table, and migrating all the data across?
Remove the server and database triggers on CREATE / DROP TABLE and CREATE / DROP PROCEDURE . Make sure there are no DDL event notifications, Memory-optimized tables and natively compiled stored procedures cannot be created or dropped if there is a server or database event notification for that DDL operation.
The syntax ALTER TABLE ... ADD/DROP/ALTER INDEX is supported only for memory-optimized tables. Without using an ALTER TABLE statement, the statements CREATE INDEX, DROP INDEX, ALTER INDEX, and PAD_INDEX are not supported for indexes on memory-optimized tables.
There are two types of indexes which can be created on memory optimized tables, namely a HASH index or RANGE index. A memory-optimized table must always have at least one index, although if you create a primary key on the table, this requirement will be satisfied.
Starting in SQL Server 2016, the query plan for a memory-optimized table can scan the table in parallel. This improves the performance of analytical queries. Hash indexes also became scannable in parallel in SQL Server 2016. Nonclustered indexes also became scannable in parallel in SQL Server 2016.
For regular tables you should use DROP INDEX
syntax:
DROP INDEX index_name ON tab_name;
ALTER TABLE
The syntax ALTER TABLE ... ADD/DROP/ALTER INDEX is supported only for memory-optimized tables.
To Drop an Index
DROP INDEX index_name ON table_name
To Add an Index
CREATE INDEX index_name ON table_name(column1, column2, ...);
Drop index on memory optimized table can be done only using alter table statement
Alter table table name DROP INDEX index name
or non memory optimized tables
DROP INDEX index name ON table name
Memory optimized tables are being supported from sql server 2016.
Look here: if it is NOT a memory optimized table then just use the "drop index" statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With