SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Function to Expand Tab Characters

By Phil Factor,

This is a function that turns tab characters into spaces. This is not as easy as one might think because of the way that tab characters work. In a non-proportionally spaced text layout, text is positioned according to the number of spaces, which are regarded as being the width of a column. A tab character moves the insertion point to the next tab position. Tab positions are every eighth column.

I suspect that there is an easier way of doing it!- however this routine seems to work and it is fast enough for my purposes.

Total article views: 2067 | Views in the last 30 days: 2
Related Articles

Detecting Specific Characters in a Varchar Field

spaces or invalid characters


Get given character's position from a string

Get given character's position from a string


Prevent repeating space characters from being stripped from rendered report?

White space is stripped from rendered report. Can we keep the spaces?



USE CASE: When we are working on TSQL or some text based scripting we may need some extra space in b...


T-SQL: Identifying, inserting and removing spaces in strings

Frequently, when working with strings you will need to identify, insert or remove spaces before, aft...

string manipulation