none
Ascii table in SQL

    Question

  • create table #ASCII(id int, a char(1))
    declare @x INT
    set @x=0
    while @x<=255
    begin
    insert into #ASCII
    select @x, char(@x)
    set @x=@x+1
    end
    
    select *
    from #ASCII
    
    drop table #ASCII
    
    hi any kind way for ASCII table ?

    OR Vs XOR

    Saturday, July 06, 2013 2:51 PM

Answers

All replies

  • try,

    with Tally (N)
    AS
    ( select top 255 row_number() over (Order By Name) from sys.columns
    )
    select N-1  as CHARVALUE,CHAR(N-1) as ASCIICHAR
    from Tally

    check http://stackoverflow.com/questions/13712070/special-character-in-sql

    http://www.sqlservercentral.com/Forums/Topic1151028-391-1.aspx


    Saturday, July 06, 2013 3:03 PM
  • You can materialize a table with the ASCII codes or create one dynamically in a query.  But be aware that only the code points 0-127 are ASCII characters.  Characters in the range 128-255 are determined by the character code page (collation in SQL Server):

    WITH 
    	t4 AS (SELECT n FROM (VALUES(0),(0),(0),(0)) t(n))
    	,t256 AS (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 0)) - 1 AS id FROM t4 AS a CROSS JOIN t4 AS b CROSS JOIN t4 AS c CROSS JOIN t4 AS d)
    SELECT 
    	id
    	, CHAR(id) COLLATE SQL_Latin1_General_CP1_CI_AS AS CP1252_Char
    	, CHAR(id) COLLATE SQL_Latin1_General_CP437_CI_AS AS CP437_Char
    FROM t256;


    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

    Saturday, July 06, 2013 5:06 PM