Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Object already exists, but can't drop it! Expand / Collapse
Author
Message
Posted Tuesday, April 15, 2014 5:49 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 1:11 PM
Points: 12,905, Visits: 32,161
well i can think of two things that might explain this:

1: you are not a sysadmin, and the object in question is outside of your permissions scope. ie the sysadmin created a table/procedure/function/view named "HighCharacter", so it exists, but you cannot see it due to permissions. this is most likely true, since your LIKE statement on sys.objects did not return the object in question.

2. a little tunnel vision possibility: you want to create a FUNCTION named "HighCharacter", but a Table,View or Procedure already exists by that name.
DROP FUNCTION would fail, becuase it should be DROP PROCEDURE, maybe.

select 
schema_name(schema_id) As SchemaName,
name As ObjectName,
type_desc as ObjectType
from sys.objects where name = 'HighCharacter'

Create your Function with a different name, like as HighCharacterV2 and i bet it works just fine.


Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1561821
Posted Tuesday, April 15, 2014 7:45 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, April 29, 2014 8:06 PM
Points: 8, Visits: 30
Lowell (4/15/2014)
well i can think of two things that might explain this:

1: you are not a sysadmin, and the object in question is outside of your permissions scope. ie the sysadmin created a table/procedure/function/view named "HighCharacter", so it exists, but you cannot see it due to permissions. this is most likely true, since your LIKE statement on sys.objects did not return the object in question.

2. a little tunnel vision possibility: you want to create a FUNCTION named "HighCharacter", but a Table,View or Procedure already exists by that name.
DROP FUNCTION would fail, becuase it should be DROP PROCEDURE, maybe.

select 
schema_name(schema_id) As SchemaName,
name As ObjectName,
type_desc as ObjectType
from sys.objects where name = 'HighCharacter'

Create your Function with a different name, like as HighCharacterV2 and i bet it works just fine.


Hi Lowell,

I think there must be either something I'm missing or there is actually a fault within something in SQL. I'm using the SA account and have confirmed it has sysadmin role. Also your select query returns nothing, no matches found.

My understanding of SA with sysadmin was full access (it doesn't even check permissions), is that true? If so why can't I see it.
I attempted the drop command for every object type I could think of; table,view,function, procedure,trigger, keys, constraint etc -- All returned same error.
Creating the function with a new name works fine as expected. - We can't simply use a new name because the function is called in literally thousands of places. We have managed to implement a workaround into the business critical procedures so they are able to work but its not ideal.

I asked the client to attempted a backup and restore, still not luck. The restored DB still has the issue.

I happy to keep on looking into suggestions, however, my feel this is actually some kind of fault.
Does anyone know, where I can take the problem from here, as in MS support and what is the process?
Post #1562094
Posted Thursday, April 17, 2014 8:09 AM This worked for the OP Answer marked as solution


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Yesterday @ 12:25 PM
Points: 242, Visits: 1,309
Did you try running a dbcc checkdb on the database its supposed to be in? Are you getting any errors from your storage/san?
Post #1562674
Posted Thursday, April 17, 2014 8:16 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 3:27 PM
Points: 20,734, Visits: 32,505
Try this and let us know the results:


select
schema_name(schema_id) As SchemaName,
name As ObjectName,
type_desc as ObjectType
from sys.all_objects where name = 'HighCharacter'





Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1562679
Posted Friday, April 18, 2014 6:12 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 7:28 AM
Points: 5,584, Visits: 6,380
I always run into this problem when it's an object with a different schema than dbo. See if my article about Dropping Schema Owned Tables helps you out. It's about tables, but the same principal applies.

Brandie Tarvin, MCITP Database Administrator

Webpage: http://www.BrandieTarvin.net
LiveJournal Blog: http://brandietarvin.livejournal.com/
On LinkedIn!, Google+, and Twitter.

Freelance Writer: Shadowrun
Latchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.
Post #1562986
Posted Monday, April 28, 2014 3:12 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, April 29, 2014 8:06 PM
Points: 8, Visits: 30
Hi All,

Sorry for the extremely late response.
Your suggestion ended up leading me to the solution. I had actually already tried it against the DB and wasn't going to bother trying again, however, eventually did and and errors where reported. I'm not sure if I made a mistake the first time or something changed however, this command with the repair switch and then the repair allow data loss worked perfectly.

thanks HEAPS for your suggestion, much appreciated.
Post #1565481
Posted Monday, April 28, 2014 4:39 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 7:28 AM
Points: 5,584, Visits: 6,380
ty 54262 (4/28/2014)
this command with the repair switch and then the repair allow data loss worked perfectly.


Ouch. You should be leery of ever using the "allow data loss" switch with that command. It literally means that data will be lost if the command needs to cut it out of the system.

I recommend you restore from a backup of the database. In fact, google "Gail Shaw allow data loss" to see all the reasons why you should not have used that option.


Brandie Tarvin, MCITP Database Administrator

Webpage: http://www.BrandieTarvin.net
LiveJournal Blog: http://brandietarvin.livejournal.com/
On LinkedIn!, Google+, and Twitter.

Freelance Writer: Shadowrun
Latchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.
Post #1565510
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse