Click here to Skip to main content
Click here to Skip to main content

I don’t know why my boss always gets angry

, 12 Jun 2011
Rate this:
Please Sign up or sign in to vote.
I don’t know why my boss always gets angry when I alter Microsoft SQL Server database objects such as storedProcedure, functions, views, etc.
Introduction
 
My friend has been working in a Software Company as a “Database Developer” for the last couple of years. When we met for some reason, most of the time I find out that he is very upset. Several times, I asked him why he was looking so upset, and every time he didn't reply to my question.
 
Background
 
One evening, he came to my home and told me that he didn't know why his boss was always getting angry when he altered the Microsoft SQL Server database objects such as storedProcedure, functions, views, etc.
 
Discussion
 
I just smiled and said, "Don’t worry, my friend, I will show you why."
In this section, I would link to show you why DROP AND CREATE database objects is much better than the alter objects. Let’s consider the scenario listed below:
 
(i) For example, we will create a simple storedProcedure name “[dbo].[spGetEmployees]” first.
(ii) Get that storedProcedure information from the system table by executing “sp_help”. Figure (a) shows the created time, after creating and performing ALTER.

Figure (A)


Figure-A
(iii) Record the storedProcedure created time.
(iv) After few minutes, alter the storedProcedure and do the scenario (ii) again.
(v) Few minutes later, do some update to the storedProcedure and this time we do not use ALTER, we use DROP AND CREATE process. Finally, do the scenario (ii) again. Figure (b) shows the created time which is updated, after creating and performing DROP AND CREATE.
 

Figure (B)


Figure-B
 

Result
 
Do you find anything that makes sense; I hope you got the point, after creating an SQL database object and you alter over and over again, the created time of that object remaining the same. Sometimes, we need to track database object modification information.
 
Conclusion
So I would always prefer “DROP AND CREATE” rather than the ALTER statement.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Md. Marufuzzaman
CEO
Bangladesh Bangladesh
n/a
Follow on   Twitter

Comments and Discussions

 
QuestionYou can use sys.objects modify_date PinmemberNicola Tufarelli12-Mar-13 7:54 
GeneralReason for my vote of 3 I'd like to see another example.. :( PinmemberINRIP16-Jun-11 9:28 
GeneralReason for my vote of 1 Ugg. PinmemberKeep on Truckin'13-Jun-11 15:11 
Reason for my vote of 1
Ugg.
GeneralHi Deeksha Shenoy: Thanks a lot..... PinmentorMd. Marufuzzaman12-Jun-11 5:50 
QuestionAnother situation to prefer "ALTER" than "DROP / CREATE" PinmemberWolle Wagner20-Jun-11 11:37 
AnswerRe: Another situation to prefer "ALTER" than "DROP / CREATE" PinmvpMd. Marufuzzaman11-Jul-11 6:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 12 Jun 2011
Article Copyright 2011 by Md. Marufuzzaman
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid