Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Drop and again create SP will that help???

Author  Topic 

under2811
Constraint Violating Yak Guru

366 Posts

Posted - 2008-06-05 : 03:05:08
Hi
I am wana to know why we every time drop the procedure and again create it as below...will that impact on performance or compilation of SP???

Use Northwind
GO
IF OBJECT_ID('dbo.ListCustomersByCity') IS NOT NULL
DROP PROC dbo.ListCustomersByCity
GO
CREATE PROCEDURE dbo.ListCustomersByCity @Country nvarchar(30)='%'
AS
SELECT City, COUNT(*) AS NumberOfCustomers
FROM Customers
WHERE Country LIKE @Country
GROUP BY City
GO

T.I.A

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2008-06-05 : 03:52:57
You will impact performance in as far as everytime this is re-created and run again, the SP will need to create a new query plan.

What do you mean about impacting compilation?!?
Go to Top of Page

under2811
Constraint Violating Yak Guru

366 Posts

Posted - 2008-06-05 : 03:56:16
u mean it is bad practise to do it like this...

T.I.A
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2008-06-05 : 04:02:13
In 2005, yes, unless there is a very specific reason for it. If you are changing the SP constantly, then why are you using an SP, if the changes are significant, then its not a problem as it would need to get a new plan anyway.
Go to Top of Page

suresha_b
Yak Posting Veteran

82 Posts

Posted - 2008-06-05 : 06:04:34
ALTER can be used instead of DROP and CREATE.

If you DROP and CREATE, you have to again GRANT previlages.
Go to Top of Page
   

- Advertisement -