RE: [mugh-sqlcon] Deleting one Index from remote database scripts
This is cool
From: Rajkumar S [mailto:srk_dba@...]
Sent: Tuesday, July 06, 2004 4:40 PM
Subject: Re: [mugh-sqlcon] Deleting one Index from remote database scripts
Drop index statement does not allow you to use databasename as prefix to the indexname. Instead you can write a stored procedure in the other database to delete the index which accepts index name as parameter and call that storedprocedure from current DB Procedure.
I want to drop one index from via one stored procedure,
But the thing is:-
My procedure will be executed in one database but the index which I want to delete is exists on a table which is in other database.
Is is possible to do so? If so how should I go with this?
Thanks in advance
- Date: Wed, 7 Jul 2004 09:17:16 +0530
X-Mailer: Internet Mail Service (5.5.2656.59)
SOLUTION FROM SQLBANG
To achieve the same you cannot execute the same directly. But having said
that you can always use the D-SQL way to achieve the same as:
Create table vin_Temp (DeptCode Int, DeptName Varchar(30)
Select * from vin_Temp
Create clustered index vin_temp_idx1 On vin_Temp(DeptCode)
Exec sp_executeSQL N'Use NorthWind;Drop Index vin_temp.vin_temp_idx1'
This for sure works :). If the same is on another server then create a
linked server and then execute using the four part name.