April 26, 2010 at 11:30 pm
Comments posted to this topic are about the item convert string to ascii values
April 30, 2010 at 3:21 am
Alternatively, using a Tally table (see link in my sig) to avoid the loop:
declare @x nvarchar(100)
set @x = 'AZ az' + char(160) + '01' -- note: 160 is an html non breaking space
SELECT
SUBSTRING(@x,N,1), ASCII(SUBSTRING(@x,N,1))
FROM
Tally
WHERE
N <= LEN(@x)
April 30, 2010 at 4:15 am
A very similar script is in BOL if you look up CHAR.
April 30, 2010 at 7:49 am
Cool. I did not know that, but I see it now. Usually when I look for code examples I don't search BOL, I search this site. If I don't find what I need, it's time to contribute code. Thanks.
May 1, 2010 at 5:03 pm
Jon McGhee (4/30/2010)
Cool. I did not know that, but I see it now. Usually when I look for code examples I don't search BOL, I search this site. If I don't find what I need, it's time to contribute code. Thanks.
I have to ask then... do you know what a Tally table is and how it works to replace While Loops? And, no, I'm not trying to be a smart guy here.
--Jeff Moden
Change is inevitable... Change for the better is not.
May 1, 2010 at 5:07 pm
LondonNick (4/30/2010)
A very similar script is in BOL if you look up CHAR.
Agreed... and it shouldn't be used either. 😉
For those that haven't seen it, please see the following for how a "Numbers" or "Tally" can be used as a very high performance replacement for certain types of While Loops...
http://www.sqlservercentral.com/articles/T-SQL/62867/
There are dozens of uses for such a table.
I also agree with Jon... if you find something that may be useful, it's impossible to know if it posted somewhere else or even in BOL. Nothing wrong with posting something you may think is useful even if it's documented in BOL. After all, there are still a lot of folks that don't even know what BOL is never mind having actually read it from top to bottom.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply