Posts tagged SQL Server

Transpose SQL Dates in Microsoft Word

0
Today I worked out how to transpose SQL dates (copied from SQL Server) in Microsoft Word: Bring up the Find and Replace dialog box. Enter the following: Find what: ([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2}).000 Replace with: \3/\2/\1 And enable “Use wildcards”

Return the MAX of all dates within all tables within all databases

0
I wanted to produce a list of the MAX of date fields (DateTime, SmallDateTime, TimeStamp) for all tables within all databases held in an instance of SQL Server. The script below was written for SQL Server 2000, but should be easily customisable for SQL Server 2005 As always, please ensure you test [...]

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

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

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

SQL function to highlight text that has been searched for

0
The SQL Server function below, can be used to highlight text (while preserving the case) that has been searched for within a web page. For example: Source: “This is the source text” Search: “source” Function call: SELECT dbo.fnHighlightSearchText('source', 'This is the source text') Return [...]

REPLACE Multiple Spaces with One

0
I have just found a very useful article from SQLServerCentral.com, that goes through the process of replacing multiple spaces with one. “Replacing multiple spaces with a single space is an old problem that people use loops, functions, and/or Tally tables for. Here’s a set based method for replacing [...]
Go to Top