Create temporary table for numbers : Temporary Table « Table « SQL Server / T-SQL






Create temporary table for numbers


-- Create temporary table for numbers:
Create Table #ASCIIVals (ASCIIValue SmallInt)
   
-- Insert numbers 0 - 127 into table:
Insert Into #ASCIIVals (ASCIIValue) Select 0
Insert Into #ASCIIVals (ASCIIValue) Select 1
Insert Into #ASCIIVals (ASCIIValue) Select 2
Insert Into #ASCIIVals (ASCIIValue) Select 3
Insert Into #ASCIIVals (ASCIIValue) Select 4
Insert Into #ASCIIVals (ASCIIValue) Select 123
Insert Into #ASCIIVals (ASCIIValue) Select 124
Insert Into #ASCIIVals (ASCIIValue) Select 125
Insert Into #ASCIIVals (ASCIIValue) Select 126
Insert Into #ASCIIVals (ASCIIValue) Select 127
   
-- Return all integer values and corresponding ASCII characters:
SELECT ASCIIValue, CHAR(ASCIIValue) As Character FROM #ASCIIVals


           
       








Related examples in the same category

1.A double pound sign denotes a global temporary object that is visible to all connections as long as the connection that created it is still active
2.Local temporary tables are removed at the end of the current session