Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Worst Practice - Adding a Column Without Thinking!


Worst Practice - Adding a Column Without Thinking!

Author
Message
Andy Warren
Andy Warren
SSCrazy Eights
SSCrazy Eights (9.2K reputation)SSCrazy Eights (9.2K reputation)SSCrazy Eights (9.2K reputation)SSCrazy Eights (9.2K reputation)SSCrazy Eights (9.2K reputation)SSCrazy Eights (9.2K reputation)SSCrazy Eights (9.2K reputation)SSCrazy Eights (9.2K reputation)

Group: Moderators
Points: 9203 Visits: 2725
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/c

Andy
SQLAndy - My Blog!
Connect with me on LinkedIn
Follow me on Twitter
jordanac
jordanac
SSC Veteran
SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)

Group: General Forum Members
Points: 249 Visits: 171

Adding a column in a hurry without doing checks!

Been there! Done that! and will NEVER DO IT AGAIN! It can cause total destruction and cost you more time in the end.




Andy.
broesi
broesi
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 1
Great article! This handy checklist will save me a lot of time - thanks!



David.Poole
David.Poole
SSCertifiable
SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)

Group: General Forum Members
Points: 5795 Visits: 3226

How about checking to see if the new column is actually needed?

Look at the design of what is there already and ask if it can encompass the need without the adding the extra column.

A good example of this is the need to add BIT columns. As you can't index them anyway you may as well have a generic Flags field as an integer and use a bit pattern. This way your existing design allows for additional flags (bits) at a later date.

I'm just auditing an external application and it appears that there are at least 4 ways of marking a record as being restricted from public viewing.

It looks like the database was built by 4 natural antagonists with a dislike for computers.



LinkedIn Profile

Newbie on www.simple-talk.com
noeld
noeld
SSCertifiable
SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)

Group: General Forum Members
Points: 7996 Visits: 2048

VERY NICE !

I wish my boss would read it every time I am asked to add one and "it shouldn't take me more than a couple of seconds" comes after that




* Noel
williamhoos@yahoo.com
williamhoos@yahoo.com
SSC Rookie
SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)

Group: General Forum Members
Points: 33 Visits: 1

I end up scripting just the CREATE component of all views, pocs, functions and then replacint CREATE with ALTER and runing the script in QA to incorporate all column references because it seems like the columns in a view are stored as a positional reference to the column order in the related table, rather than to a table_name.field_name reference. Does the sp_refreshviews do the same thing?





David.Poole
David.Poole
SSCertifiable
SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)

Group: General Forum Members
Points: 5795 Visits: 3226

sp_refreshview recompiles the view which achieves the same thing as running an ALTER statement



LinkedIn Profile

Newbie on www.simple-talk.com
DCPeterson
DCPeterson
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1325 Visits: 432

How about "Does the column make sense logically?" i.e. will the column take my BCNF table(s) and turn them into an unnormalized mess of redundancy and inconsistency?

This, of course, assumes that the database was designed properly in the first place.



/*****************

If most people are not willing to see the difficulty, this is mainly because, consciously or unconsciously, they assume that it will be they who will settle these questions for the others, and because they are convinced of their own capacity to do this. -Friedrich August von Hayek



*****************/
mcloney
mcloney
SSC Veteran
SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)

Group: General Forum Members
Points: 231 Visits: 83

What about DTS packages? I've had developers add columns and forget to tell me, then they wonder why things aren't working correctly when we push to production. Maddening.


Cheers,

-m





Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search