The INSERT statement in SQL Server is versatile. It now allows the insertion of multiple rows of literal values. It also provides the output clause that solves a number of common problems such as ascertaining the value of identity fields, and other calculated fields in tables, or for auditing the rows that are added to tables. Robert, once again, gives a clear introduction. … Read more
If a SQL query has parameters, SQL Server creates an execution plan tailored to them to improve performance, via a process called 'parameter sniffing'. This plan is stored and reused since it is usually the best execution plan. Just occasionally, it isn't, and you can then hit performance problems, as Greg Larsen explains.… Read more
Jonathan Lewis is an Oracle expert who is recording his exploration of SQL Server in a series of articles. In this fourth part, he turns his attention to clustered indexes, and the unusual requirement SQL Server seems to have for the regular rebuilding of indexes. … Read more
Fabiano continues his mission to explain the Query Optimiser in practical terms, describing, one week at a time, all the major Showplan Operators used by SQL Server's Query Optimiser to build the Query Plan. He discusses the Stream Aggregate function and shows how easy it is to get performance gains in GROUP BY clauses by choosing the right index.… Read more
When creating SQL Source Control, the team had to make decisions as to which source control systems the tool would support, and needed to accomodate a range of different development practices. It also had to avoid the potential problems from the fundemental differences between database builds and application builds, David and Stephanie, from the team that wrote the tool, explain what they did, and why.… Read more
Whatever happened to the idea that programming in TSQL can be fun? A Simple-Talk reader contributes an article to remind us all that there is more to TSQL than wrestling with DMVs and pumelling recalcitrant correlated subqueries.… Read more
When the SQL MERGE statement was introduced in SQL Server 2008, it allowed database programmers to replace reams of messy code with something quick, simple and maintainable. The MERGE syntax just takes a bit of explaining, and Rob Sheldon is, as always, on hand to explain with plenty of examples.… Read more
Index fragmentation can cause problems with query performance. Indexes therefore need to be occasionally rebuilt. the Rebuild Index task of the SSMS Database Maintenance Wizard drops and rebuilds every index in a database. It is effective but an off-line activity that is resource-intensive, so it not always the best way of avoiding index fragmentation in a production database. Brad explains...… Read more
You can easily re-factor bad DML code, but if a database design is wrong, you can do little to rescue the problem, even with expert queries. So what constitutes 'wrong RDBMS design? What are these errors that continually crop up? How can you recognise them and fix them? Joe embarks on a new series of articles by identifying a series of bad practices based on the habit of 'splitting' that which shouldn't be split.… Read more
Before you can tackle any performance issues with a working database, you need to know which queries to work on first: The ones that are taking the most time in total, and which are the most expensive in terms of cache, CPU and disk. Although SQL Server Management Studio can help, it isn't long before you need an armoury of DMVs to provide you the statistics to find the culprits. … Read more
On Ask.SQLServerCentral.com, a group of people interested in experimenting with heavily optimised SQL techniques try them out on a problem, using reasonbly large amounts of data. They aren't so interested in explaining the techniques, so Kathi continues on her mission to explain the lessons learned and the tips that can be derived.… Read more
In the first of a series of in-depth software reviews, Brad investigates a newcomer, SQL Virtual Restore. What does it aim to do? How does it achieve it? Why is it safe to use? What are the benefits? Brad aims to answer a range of questions fairly and squarely.… Read more
It is a question every development manager dreads; "So how does your company handle database changes?". The reply usually masks a multitude of sins against all the canons of version control. Mike has seen most of these sins and, like the ancient mariner, is keen to give you the awful warning, 'Neglect database source control at your peril'.… Read more
One irritating thing for the occasional SQL Server Developer is that the experts assume that you are familiar with the use of number tables when they write about techniques. We therefore asked Greg Larsen to spell it out in a way that would help the beginner and intrigue those already familar with the technique. … Read more
One of the more important tasks in the process of rolling out incremental developments to a multi-server production system is to double-check that all of the planned modifications, and nothing else, have been deployed. An Oracle expert, Bruce Armstrong, comes across SQL Compare for Oracle, and sees if it helps with this time-consuming task.… Read more
Often, there is a huge difference between software being easy to use, and easy to develop. When your pilot users tell you "by week three of any development project you've thrown out anything that takes time or just gets in your way", then it is time to be serious about usability, as well as quality. We decided to find out from some of those at the sharp end of the development of Red Gate's SQL Source Control.… Read more
In retrospect, it was probably the inclusion of the OUTPUT clause in the MERGE statement that gave SQL Server 2008 its most powerful SQL enhancement.. It isn't the easiest of features to explain, but Bob does it in his usual clear and careful way.… Read more
To make progress as a relational Database programmer, you have to think in terms of sets, rather than lists, arrays or sequential data. Until that point, you'll feel the need to pass lists, arrays and the like to functions and procedures. Joe suggests some unusual ways around the difficulty and broods on the power of the VALUES constructor.… Read more
If you ever feel uneasy when you set about handcrafting database maintenance jobs for SQL Server, it may be the voice of your conscience saying 'Ola, Ola!'. Follow your conscience. Ola Hallengren has already crafted a superb set of routines to do this for you. Why reinvent something that does it all, safely and well. Brad McGehee explains....… Read more
If you are not keen on repetitive typing, you can still rapidly produce production-quality documented code by planning ahead and using Extended properties, and system views. Phil Factor explains, with some Scary SQL… Read more