If you want to create pivoted tables but found the PIVOT operator syntax in SQL Server Books Online (BOL) confusing, try this three-step approach to creating a PIVOT query. This query uses a common table expression (CTE).
Some refinements to Index_Evaluation_USP make this T-SQL stored procedure more effective and easier to use to identify tables without indexes, indexes that aren't being used, and indexes that aren't being used efficiently.
Although set-based solutions to running aggregations have many advantages over cursor-based solutions, cursor-based solutions can provide better performance in certain cases, such as when dealing with very large partitions.
Deleting all the records in a database can be tricky when it includes tables with foreign keys. Here's a script you can use if you have ALTER TABLE permission and a stored procedure you can use if you don't.
Stored procedures, user-defined functions, views, and triggers can fail to execute when the objects they reference have been changed. Here's a tool you can use to detect broken objects before they cause problems.
Using a looping algorithm to determine the average number of days between orders can be painfully slow code to write and run. A better approach is to use the ROW_NUMBER function.
BI xPress,now available from Pragmatic Works, integrates with Business Intelligence Development Studio (BIDS) and Visual Studio to standardize your SQL Server Integration Services (SSIS) package deployments without manual coding.
After discovering a useful T-SQL stored procedure, a reader and his coworkers adapt it so it can perform more types of searches and more refined searches when needed.
Both the subquery and join solutions perform reasonably well for calculating running aggregates when you have very small partitions, but the join approach is best for calculating multiple aggregates.
Looking for an object in a SQL Server instance without knowing the object's exact name and the database in which it resides can be time-consuming. Here's a T-SQL stored procedure that will make your seach much quicker.