THE SQL Server Blog Spot on the Web

Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | |
in Search

John Paul Cook

Bad Habits to Kick: Using Alter Instead of Create to Look at Code

It's a pretty common thing to right-click on a stored procedure, function, or view to look at the source code. Understand that I'm specifically limiting the scope to looking at the T-SQL code, not changing it. You have the option to script the procedure, function, or view as either a CREATE script or an ALTER script. If you use ALTER, you're at risk of accidentally changing the code. If you use CREATE and you do hit F5 or execute, you'll get an error message stating that the procedure, function, or view already exists. Your code won't be changed.

image

Published Wednesday, October 14, 2009 1:02 PM by John Paul Cook

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

jerryhung said:

I totally agree with you, use CREATE to prevent modifying the procedure/code by accident

October 15, 2009 3:46 PM

Leave a Comment

(required) 
(required) 
Submit

About John Paul Cook

John Paul Cook is both a Registered Nurse and a Microsoft SQL Server MVP experienced in Microsoft SQL Server and Oracle database application design, development, and implementation. He has spoken at many conferences including Microsoft TechEd and the SQL PASS Summit. He has worked in oil and gas, financial, manufacturing, and healthcare industries. Experienced in systems integration and workflow analysis, John is passionate about combining his IT experience with his nursing background to solve difficult problems in healthcare. He sees opportunities in using business intelligence and Big Data to satisfy healthcare meaningful use requirements and improve patient outcomes. John graduated from Vanderbilt University with a Master of Science in Nursing Informatics and is an active member of the Sigma Theta Tau nursing honor society. Contributing author to SQL Server MVP Deep Dives and SQL Server MVP Deep Dives Volume 2.

This Blog

Syndication

Powered by Community Server (Commercial Edition), by Telligent Systems
  Privacy Statement