Friday, March 31, 2017

5 Rules for TSQL Programming

It's nearly impossible to be a software engineer without interacting directly with databases.  In many large companies you'll find that Microsoft SQL is a staple, and it really helps to know TSQL very well.  Whether you're an expert or a beginner, it helps to follow these five simple rules.

1. Backups.  Make sure you have a daily backup schedule, and that you make backups before you make any changes.  You will never regret having backups.

2. Always do your work on a development server.  It should go without saying, but you should never log into a production server unless you absolutely have to.  In fact, try to have your access to prod servers revoked completely if you can.  If your company doesn't have a dev server, push for one.  If you can't get one, install SQL Server Express on your development machine and load the tables with dummy data.

3. Save your TSQL scripts in version control software.  A lot of developers that have to do a lot of TSQL really like Redgate, and it is actually really sweet.  Unfortunately it doesn't seem to be that well known, and the licensing for it can be expensive.  If you don't have it, your regular version control software will suffice.

4. Try to keep it simple.  I know, it's easier said than done with TSQL stored procs a lot of the time.  But simplicity will almost always benefit you.

5. Use automation to deploy to production.  When it's time to deploy to production, you're going to want to automate it as much as possible to minimize the chance of human errors.  There are a lot of great CI (continuous integration) software suites out there like Jenkins, Bamboo, Travis, and TeamCity that can handle it (Jenkins is my current favorite); or, at the very least use scripts that you have thoroughly tested on your development server.

Let me know what you think.  Do you agree or disagree with any of these rules?  Is there something important that I didn't mention?  I want to hear about it, let me know!


No comments:

Post a Comment