December 2, 2010 at 5:00 am
hi there,
i'm playing with SQL Server 2008 on my XP-Workstation.
I created a table and some indexes on it - so I'm the dbo for this table, right?
I can see the created indexes (sp_helpindex testen).
Wenn I try to: Drop Index test1 on testen.myfield
I get an error saying: cannont find testen.myfield or I don't have permission (both are false, I suppose..).
What's wrong?
December 2, 2010 at 5:13 am
Please post the create statement for both the table and indexes and the drop statement you are trying to execute.
December 2, 2010 at 5:24 am
create table testen
(iid int not null, strasse varchar(50), plz varchar(10))
insert testen
values (3,'gutes 12','1123')
create nonclustered index strasse on testen(strasse)
sp_helpindex testen
ALTER INDEX strasse ON testen.strasse
REBUILD; => here I get an error saying: 'Msg 1088, Level 16, State 9, Line 1
Cannot find the object "testen.strasse" because it does not exist or you do not have permissions.'
December 2, 2010 at 5:36 am
it's the tablename: the table is not "testen.strasse", it is "testen" or "dbo.testen"
the code is looking for a schema testen and a table strasse, which does not exist.
ALTER INDEX strasse ON testen
REBUILD;
Lowell
December 2, 2010 at 5:48 am
upps..
thank you for your help, it works!
I was just thinking:
DROP Index table_name.index_name
also must be:
ALTER INDEX index_name ON table_name.index_name REBUILD;
but I was wrong...
December 2, 2010 at 6:09 am
I'm not sure you guys are talking about the same thing :
Rebuild is used to make a copy of the index and drop the old one (which 100% defrags it in the process).
Drop means delete.
December 2, 2010 at 7:01 am
karl-heinz (12/2/2010)
upps..thank you for your help, it works!
I was just thinking:
DROP Index table_name.index_name
also must be:
ALTER INDEX index_name ON table_name.index_name REBUILD;
but I was wrong...
In SQL Server index names must be unique by table, but not by schema (as it is the case in DB2 for example). This means the same index name can exist in different tables and therefore you need to tell the system in which table you wish to drop it.
brgds
Philipp Post
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply