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

I don’t know why my boss always gets angry

By , 12 Jun 2011
 
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
Member
He is the founder & CEO of MNH Technologies and working for urban and rural sectors to improve people’s lifestyle, better medical facilities, education, social business etc. He has over ten years of professional experiences in design and developing Client-Server, Multi-Tier, Database, Web based business software solutions, Enterprise Applications, API, WebAPI, Google Analytics implementation, Add-In, Documentation & Technical Writing etc for Windows / Mac using Microsoft SQL Server, Oracle, MySql, PS, C#, VB.NET, ASP.NET, PHP, RoR, Visual Basic etc. He has also more than two years experience in Mobile-VAS (Platform Development).
 
He worked for various software development & technology consulting. His core focus on technologies to create dynamic data-driven systems that add value to your business and dynamic technology consulting that builds advanced solutions for the industries across the various vertices.
 
He also work as a Solution Architect at Dhrupadi Techno Consortium Limited (DTCL) and responsible for analyzing business requirements and offered optimum solutions (multiple options), which would address all current requirements, provide flexibility for future growth and allow smooth transition between old system and new system.
 
He graduated with honors from The University of Asia Pacific, in Computer Science and Engineering. He was awarded as “Most Valuable Professional” (MVP) at 2010 and 2011 by CodeProject.com and also selected as a Mentor of CodeProject.com
 
Specialties: Software Development Management, System Integration, Data Warehouse Architecture, Virtualization.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionYou can use sys.objects modify_datememberNicola Tufarelli12 Mar '13 - 7:54 
Starting from SQL Server 2005 you may have the last modify date of an object using
select * from sys.objects
the modify_date column has the correct value.
If you try this in SQL Server 2000 however the modify_date is not updated, so it is useless.
GeneralReason for my vote of 3 I'd like to see another example.. :(memberINRIP16 Jun '11 - 9:28 
Reason for my vote of 3
I'd like to see another example.. :(
GeneralReason for my vote of 1 Ugg.memberKeep on Truckin'13 Jun '11 - 15:11 
Reason for my vote of 1
Ugg.
GeneralHi Deeksha Shenoy: Thanks a lot.....mentorMd. Marufuzzaman12 Jun '11 - 5:50 
Hi Deeksha Shenoy: Thanks a lot.....
QuestionAnother situation to prefer "ALTER" than "DROP / CREATE"memberWolle Wagner20 Jun '11 - 11:37 
I'm not quite sure to remember it correctly, but:
 
You do lose assignments of the SP to a database role after the SP is dropped.
You will have to execute grant execution rights after each "DROP/CREATE" of a stored procedure.
Unless the process of DROP/CREATE/GRANT is not automated, this might get annoying.
 
Re-Granting rights is not necessary if you use ALTER.
 
Regards, Wolfgang.
AnswerRe: Another situation to prefer "ALTER" than "DROP / CREATE"mvpMd. Marufuzzaman11 Jul '11 - 6:42 
Thanks, probably you are right.
Thanks
Md. Marufuzzaman


I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 12 Jun 2011
Article Copyright 2011 by Md. Marufuzzaman
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid