Sort results based on a Stored Procedure parameter

0
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. Example: Firstly, here is the declaration (it can easily be changed into a stored procedure): DECLARE @OrderBy [...]

Count the number of records in each table within a database

0
The Transact-SQL script below (written for SQL Server 2000, but also works with 2005), returns a list of tables and a count of the number of records within each table. USE [database name] GO DECLARE @name VARCHAR(500) DECLARE @sql VARCHAR(1000) CREATE TABLE #TableRecordCount ( TableName [...]

Come and see my new forum

0
Hi. I have just added a forum to my site, that can be accessed using the option in the menu, or by clicking HERE. Please use the forum to post any questions you may have, or to see if there is any solutions to problems you have encountered.

Finding table column names with a specific word

0
The code below 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. SELECT     CASE O.xtype WHEN 'U' THEN 'Table' WHEN 'V' THEN 'View' END AS Type,     O.name AS TableName,     [...]

Fatal error after upgrading User online (wp-useronline) plugin

0
When I upgraded the User Online plugin (wp-useronline) a short while ago, I got a Fatal Error: Fatal error: Call to undefined method scbOptions::get_key() in …/wp-content/plugins/wp-useronline/admin.php on line 56 I looked on Google and found the WordPress Support page [...]

Red Gate’s SQL Search

0
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 [...]

Median function for SQL Server

0
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 [...]
Go to Top