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)
(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)
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.
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.