One of the things that many developers learn over time is that they write better code with practice. In fact, some of the time a developer will find that if they write a bit of code to solve a problem, they'll come up with a better solution a day or two later, as they've had a chance to think about the problem. Even while moving on to other code, their brain will continue to examine the previous solution, inherently knowing the approach wasn't the best.
Many of us see this with our code over time. If we look back at something we wrote a year or two ago, many of us cringe. At least, most of us cringe, especially if we constantly look to improve our skills. We see that old code as poorly written, in a way that we might never want to repeat in our career. I think that's a good sign that we are moving forward and learning better patterns over time. If you don't view any of your old code as poorly written, I'd stop and get a second opinion. You certainly might have written some great routines that stand the test of time, but more often than not, I find places where I'd improve code. Having someone else review my work might help me build better skills.
One of the things I heard recommended recently was that developers solve some problem, commit the code in their VCS, and then tomorrow, redo the work. Start the day by deleting that section of code (that proc, method, class, etc.). Then move forward and rewrite the solution, not trying to remember what was there, but by resolving the issue. Plenty of application developers find they'll write similar logic, but better structured code. Even if you don't believe this, conduct an experiment on a small section of your code.
I don't know if we'd come up with the same results with T-SQL as many of us tend to solve the problems the same way across a short period of time. However, maybe you'd like to post a mock up of your challenge and solution, and ask for some opinions. We have great forums at SQLServerCentral and some really sharp SQL developers. You might get the validation that you built a great solution, or maybe you'd get some ideas on how to improve both your code and your skills.
The Voice of the DBA podcast features music by Everyday Jones. No relation, but I stumbled on to them and really like the music.
Stop your database being a bottleneck
The new Redgate Hub is the shortcut to the latest insights into database development. Constantly updated with invaluable content, it’s the one resource you need to solve problems, share ideas, discover new tool features, and expand your database skills. Discover the Redgate Hub
SQL Clone: Now supporting databases up to 64TB
Create copies of production databases and SQL backups in seconds and save up to 99% of disk space using SQL Clone. Redgate’s new tool removes much of the time and resource needed to create and manage database copies, allowing teams to work on local environments to develop, test and diagnose issues faster. Try it free
When a SQL Server database is operating smoothly and performing well, there is no need to be particularly aware of the transaction log, beyond ensuring that every database has an appropriate backup regime and restore plan in place. When things go wrong, however, a DBA's reputation depends on a deeper understanding of the transaction log, both what it does, and how it works. More »
Azure Data Factory is a cloud based data integration service. This helps you to define, schedule and manage data pipelines to transfer and transform the data from disparate on premise and cloud data sources. Read on to learn more. More »
SQL Server T-SQL Recipes is an example-based guide to the Transact-SQL language that is at the core of SQL Server. This edition has been lightly updated for SQL Server 2014 and provides ready-to-implement solutions to common programming and database administration tasks. Learn to create databases, create in-memory tables and stored procedures, insert and update data, generate reports, secure your data, and more. Get your copy from Amazon today.
Strange COALESCE issue
I think it's correct to provide a table structure for any questions so I'll include that first:
/****** Object: Table...
- Hi All,
I am using SQL below to get the object dependency.
select Obj.name,dep.referenced_entity_name from sys.sql_modules as Module,sys.objects AS Obj ,sys.sql_expression_dependencies
This newsletter was sent to you because you signed up at SQLServerCentral.com.
Feel free to forward this to any colleagues that you think might be interested.
If you have received this email from a colleague, you can register to receive it here.