﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Older Versions of SQL (v6.5, v6.0, v4.2) / Older Versions of SQL (v6.5, v6.0, v4.2)  / Special Characters / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 18 Jun 2013 20:13:37 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Special Characters</title><link>http://www.sqlservercentral.com/Forums/Topic705393-1437-1.aspx</link><description>closing this thread. Please check dates before replying.</description><pubDate>Mon, 27 Dec 2010 14:39:20 GMT</pubDate><dc:creator>Steve Jones - SSC Editor</dc:creator></item><item><title>RE: Special Characters</title><link>http://www.sqlservercentral.com/Forums/Topic705393-1437-1.aspx</link><description>Stephen, you do realize this question was from May, 2 years ago (2009), right?</description><pubDate>Mon, 27 Dec 2010 14:13:47 GMT</pubDate><dc:creator>GSquared</dc:creator></item><item><title>RE: Special Characters</title><link>http://www.sqlservercentral.com/Forums/Topic705393-1437-1.aspx</link><description>Not totaly clear about if you wanted to remove all spaces or just leading?? If you are tataly striping the characters just use a series of nested "REPLACE" statements.DECLARE @str1 VARCHAR(100), @str2 VARCHAR(100), @str3 VARCHAR(100) SET  @str1 = 'A &amp; B Cleaners'SET @str2 = 'A and B Cleaners'SET @str3 = 'Cleaners A &amp; B'SELECT '*'+@str1+'*', '*'+REPLACE(REPLACE(@str1, ' ', ''), '&amp;', '')+'*'SELECT '*'+@str2+'*', '*'+REPLACE(REPLACE(@str2, ' ', ''), '&amp;', '')+'*'SELECT '*'+@str3+'*', '*'+REPLACE(REPLACE(@str3, ' ', ''), '&amp;', '')+'*'String   Result*A &amp; B Cleaners*	*ABCleaners**A and B Cleaners*	*AandBCleaners**Cleaners A &amp; B*	*CleanersAB*</description><pubDate>Mon, 27 Dec 2010 14:07:41 GMT</pubDate><dc:creator>Stephen.Richardson</dc:creator></item><item><title>RE: Special Characters</title><link>http://www.sqlservercentral.com/Forums/Topic705393-1437-1.aspx</link><description>Any feedback on this, Jim?</description><pubDate>Fri, 01 May 2009 21:32:59 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Special Characters</title><link>http://www.sqlservercentral.com/Forums/Topic705393-1437-1.aspx</link><description>Ok, here we go... Assuming that you have the company name in a variable and the fact that you're using a version of T-SQL that cannot use functions, here's how I'd do it...[font="Courier New"][size="2"][color="black"][/color][color="green"]--=====&amp;#160;Company&amp;#160;name&amp;#160;is&amp;#160;in&amp;#160;a&amp;#160;variable[/color][color="blue"]DECLARE&amp;#160;[/color][color="#434343"]@CompanyName&amp;#160;[/color][color="blue"]VARCHAR[/color][color="gray"]([/color][color="black"]256[/color][color="gray"])&amp;#160;[/color][color="blue"]SELECT&amp;#160;[/color][color="#434343"]@CompanyName&amp;#160;[/color][color="blue"]=&amp;#160;[/color][color="red"]'A&amp;#160;&amp;amp;&amp;#160;B&amp;#160;Cleaners'&amp;#160;&amp;#160;&amp;#160;[/color][color="blue"]PRINT&amp;#160;[/color][color="#434343"]@CompanyName&amp;#160;[/color][color="green"]--Just&amp;#160;for&amp;#160;verification...&amp;#160;you&amp;#160;can&amp;#160;remove&amp;#160;this&amp;#160;line--=====&amp;#160;Using&amp;#160;a&amp;#160;&amp;quot;Tally&amp;quot;&amp;#160;table&amp;#160;as&amp;#160;a&amp;#160;loop&amp;#160;driver,&amp;#160;remove&amp;#160;all&amp;#160;characters&amp;#160;that&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;--&amp;#160;are&amp;#160;NOT&amp;#160;in&amp;#160;the&amp;#160;in&amp;#160;range&amp;#160;of&amp;#160;A&amp;#160;to&amp;#160;Z&amp;#160;(upper&amp;#160;or&amp;#160;lower&amp;#160;case)&amp;#160;[/color][color="blue"]SELECT&amp;#160;[/color][color="#434343"]@CompanyName&amp;#160;[/color][color="blue"]=&amp;#160;[/color][color="magenta"]STUFF[/color][color="gray"]([/color][color="#434343"]@CompanyName[/color][color="gray"],[/color][color="magenta"]PATINDEX[/color][color="gray"]([/color][color="red"]'%[^A-Z]%'[/color][color="gray"],[/color][color="#434343"]@CompanyName[/color][color="gray"]),[/color][color="black"]1[/color][color="gray"],[/color][color="red"]''[/color][color="gray"])&amp;#160;&amp;#160;&amp;#160;[/color][color="blue"]FROM&amp;#160;[/color][color="black"]dbo.Tally&amp;#160;t&amp;#160;&amp;#160;[/color][color="blue"]WHERE&amp;#160;[/color][color="black"]t.N&amp;#160;[/color][color="gray"]&amp;lt;=&amp;#160;[/color][color="magenta"]LEN[/color][color="gray"]([/color][color="#434343"]@CompanyName[/color][color="gray"])&amp;#160;&amp;#160;&amp;#160;&amp;#160;AND&amp;#160;[/color][color="magenta"]SUBSTRING[/color][color="gray"]([/color][color="#434343"]@CompanyName[/color][color="gray"],[/color][color="black"]t.N[/color][color="gray"],[/color][color="black"]1[/color][color="gray"])&amp;#160;LIKE&amp;#160;[/color][color="red"]'[^A-Z]'[/color][color="green"]--=====&amp;#160;Grab&amp;#160;just&amp;#160;the&amp;#160;left&amp;#160;six&amp;#160;characters&amp;#160;of&amp;#160;what&amp;#160;remains.&amp;#160;[/color][color="blue"]SELECT&amp;#160;[/color][color="#434343"]@CompanyName&amp;#160;[/color][color="blue"]=&amp;#160;[/color][color="magenta"]LEFT[/color][color="gray"]([/color][color="#434343"]@CompanyName[/color][color="gray"],[/color][color="black"]6[/color][color="gray"])[/color][color="green"]--=====&amp;#160;Display&amp;#160;the&amp;#160;result&amp;#160;(just&amp;#160;for&amp;#160;verification...&amp;#160;you&amp;#160;can&amp;#160;remove&amp;#160;this&amp;#160;line)&amp;#160;&amp;#160;[/color][color="blue"]PRINT&amp;#160;[/color][color="#434343"]@CompanyName[/color][/size][/font]If you don't have a Tally table, please see the article at the following URL for how to build one, what it is, and how it works.  It's a very useful tool that can frequently be used to replace loops. [url]http://www.sqlservercentral.com/articles/TSQL/62867/[/url]If you need to do this to a whole table column, please post back.</description><pubDate>Wed, 29 Apr 2009 19:30:39 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Special Characters</title><link>http://www.sqlservercentral.com/Forums/Topic705393-1437-1.aspx</link><description>[quote][b]jim.rasmussen (4/28/2009)[/b][hr]Yes it does. I have researched this, but can't seem to make it work correctly. Any thoughts?ThanksJim[/quote]Sorry, Jim... I had almost 900 emails in my inbox since I posted this... I'll be back.  Thanks for the info.</description><pubDate>Wed, 29 Apr 2009 17:58:09 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Special Characters</title><link>http://www.sqlservercentral.com/Forums/Topic705393-1437-1.aspx</link><description>Yes it does. I have researched this, but can't seem to make it work correctly. Any thoughts?ThanksJim</description><pubDate>Tue, 28 Apr 2009 07:42:02 GMT</pubDate><dc:creator>jim.rasmussen</dc:creator></item><item><title>RE: Special Characters</title><link>http://www.sqlservercentral.com/Forums/Topic705393-1437-1.aspx</link><description>[quote][b]jim.rasmussen (4/27/2009)[/b][hr]I have a filed of varchar the holds names of companies. Like 'A &amp; B Cleaners'. What I what to do is to select this.. 'ABClea'. How can I get this done?ThanksJim[/quote]Wow... that does go back a bit...Does your version of SQL Server have the STUFF function available?</description><pubDate>Mon, 27 Apr 2009 19:46:23 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>Special Characters</title><link>http://www.sqlservercentral.com/Forums/Topic705393-1437-1.aspx</link><description>I have a filed of varchar the holds names of companies. Like 'A &amp; B Cleaners'. What I what to do is to select this.. 'ABClea'. How can I get this done?ThanksJim</description><pubDate>Mon, 27 Apr 2009 15:45:15 GMT</pubDate><dc:creator>jim.rasmussen</dc:creator></item></channel></rss>