Earlier today, I discovered that the database maintenance plan on one of our SQL Server machine wasn’t working. When I reviewed the logs, it simply said “sqlmaint.exe failed”.
Category: SQL Server
The query within this post returns the top 20 most used query plans that are cached by SQL Server for faster query execution.
I was on a training course at the end of September, and came across a way to execute a simple stored procedure as part of a select statement using an Inline Table Valued Function.
You (like me) have probably tried to run the following statement expecting to get results from a stored procedure:
FREE Level 400 SQL Server Performance Monitoring and Tuning Webcasts at http://www.sqlworkshops.com/webcast This is a great resource for performance monitoring and tuning 🙂
The script within this post returns a list of all tables (along with the schema name), and indexes (where they exist), and the name of the associated file group.
This will useful to find out which objects have been assigned to the wrong file group.
I have a database with over 10 file groups, and wanted to find out why there was over 50Gb of data in the PRIMARY file group, even though there were only a couple of tables in that group. When I ran this script, I discovered there were some indexes that had been incorrectly created in the PRIMARY group!!!
I needed to find out which columns within all tables in the database, contained a specific string of text. I therefore wrote a script to do exactly that 🙂
If you need to transfer the logins and passwords from one server or instance to another server or instance, please refer to this very useful article from Microsoft: How to transfer the logins and the passwords between instances of SQL Server 2005 and SQL Server 2008
If you want to be able to specify the sort criteria for the results returned from a stored procedure, based on a provided parameter, you might want to try using the “QUOTENAME” function.
The Transact-SQL script in this post returns a list of tables and a count of the number of records within each table.
The code contained in this post can be used to find all tables that contain columns that have “ADDRESS” in the name. It can easily be modified to search for table column names with any specific word.
Hi. I have just downloaded Red Gate’s FREE SQL Search tool from http://www.red-gate.com/products/SQL_Search/index.htm Features: Find fragments of SQL text within stored procedures, functions, views and more Quickly navigate to objects wherever they happen to be on your servers Find all references to an object Integrates with SSMS Why use SQL Search? Impact Analysis You want […]
I have been using a Transact-SQL query (see Method 1 – Update entire table below) to get the Median “Order Value” for an entire list of Customers. However, due to the quantity of data, it was taking for ever.
Therefore, this morning I decided to write a SQL Server User Defined Function (see Method 2 – Function below) [1. Please ensure you test any script taken from my website on a test/development machine, before running on a production server.] to update the Median Order Value for a single Customer. I then used a UPDATE query to update all of the customers. This took a lot less time to process 🙂