sql - Creating an index after dropping gives message index already exist -


i having issue dropping , creating index in sql server 2008 r2. when create index after dropping says index exists. if search index table dont see exist

get following error message

msg 1913, level 16, state 1, line 40 operation failed because index or statistics name 'ix_partiesipodata_companyid' exists on table 'corereferencestaging.dbo.partiesipodata'.

tried following

if exists(select  *  sys.indexes ind inner join   sys.index_columns ic on  ind.object_id = ic.object_id , ind.index_id = ic.index_id  ind.name = 'ix_partiesipodata_companyid')     drop index ix_partiesipodata_companyid on partiesipodata create nonclustered index ix_partiesipodata_companyid on corereferencestaging.dbo.partiesipodata(companyid)  

and this

if exists(select *  sys.indexes  name='ix_partiesipodata_companyid' , object_id = object_id('corereferencestaging.dbo.partiesipodata'))     drop index ix_partiesipodata_companyid on partiesipodata create nonclustered index ix_partiesipodata_companyid on corereferencestaging.dbo.partiesipodata(companyid)  

this how index table looks like

enter image description here

index table

just search existing name index sql server query :

select * sys.indexes name '%%' 

if same name index exist,then drop it.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -