Avatar of tablaFreak
tablaFreakFlag for United States of America

asked on 

Can't Drop Stored Procedure

Hello Experts - I'm experiencing some strange behavior - for some reason I can't update a stored proc in SQL Server 2008 R2 Express. WHen I run an ALTER command, it runs fine, but if I execute the query, it keeps giving me the old version. When I try to drop the procedure, it tells me it doesn't exist. Then if I run it again, it runs fine, and with the old version. Can't update it, can't drop it - HUH??

Any ideas?

Thanks,
Steve
Microsoft SQL Server 2008

Avatar of undefined
Last Comment
tablaFreak
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Is it possible, it is in another database? i.e., did you accidentally create the procedure under master? What does the ALTER statement look like, how are you calling it when it works -- just really need the name part, i.e., schema.procname or db.schema.procname depending on how you are calling it...maybe something is in that to give us a clue.
Avatar of OriNetworks
OriNetworks

mwvisa1 brings up a good point that i run into frequently.

Also, can you update anything else in the database? Is it possible that the procedure is in a different namespace? e.g. myname.spMyProcedure instead of dbo.spMyProcedure
Avatar of JHolycloud
JHolycloud
Flag of Indonesia image

Probably you run it in the wrong DB. Try to use :

USE [YourDBName]
GO

Open in new window


when ALTER or RUN your SP.

Hopei it helps...
Just a quick thought, did you check which schema did you set to default for? This happened to one of my developers who came yelling at me one day about why his dropped SP still alive. And what I found is that he was set to default schema as some temp schema instead of dbo. So when he creates or drops objects, SQL Server will look at his default schema in the first place. In no offense, I wish you are not in the same position.
ASKER CERTIFIED SOLUTION
Avatar of AlokJain0412
AlokJain0412
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of tablaFreak
tablaFreak
Flag of United States of America image

ASKER

Thanks for your suggestions, and yes, I've fallen prey to not running queries on the right db before, but that wasn't the case this time - when I ran that query you sent, AlokJain0412, two SPs came up with the same name. I had to run the Drop Procedure... query twice, then recreate it for the old version to actually be updated. Must have just been cached somewhere - it's working now, thanks, but I'm still baffled why simply running the 'Alter procecure' statement didn't update it. Mysteries...

Thanks
Avatar of tablaFreak
tablaFreak
Flag of United States of America image

ASKER

fixed the problem, but the underlying reason remains a mystery.
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

The query supplied included neither the CATALOG nor the SCHEMA, so mystery would have been removed by seeing where they lived. Anyway, glad you are fixed now. :)
Avatar of tablaFreak
tablaFreak
Flag of United States of America image

ASKER

Gotchya - thanks, if it happens again I'll know what to do. Cheers.
Microsoft SQL Server 2008
Microsoft SQL Server 2008

Microsoft SQL Server 2008 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. Major improvements include the Always On technologies and support for unstructured data types.

50K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo