看看,可能有帮助CHAR (T-SQL) A string function that converts an int ASCII code to a character.Syntax CHAR(integer_expression)Arguments integer_expression Is an integer from 0 through 255. NULL is returned if the integer expression is not in this range. Return Types char(1)Res CHAR can be used to insert control characters into character strings. The table shows some commonly used control characters. Control character Value Tab CHAR(9) Line feed CHAR(10) Carriage return CHAR(13) Examples A. Use ASCII and CHAR to print ASCII values from a string This example prints the ASCII value and character for each character in the string New Moon.SET TEXTSIZE 0-- Create variables for the character string and for the current -- position in the string.DECLARE @position int, @string char(8)-- Initialize the current position and the string variables.SET @position = 1SET @string = 'New Moon'WHILE @position <= DATALENGTH(@string) BEGIN SELECT ASCII(SUBSTRING(@string, @position, 1)), CHAR(ASCII(SUBSTRING(@string, @position, 1))) SET @position = @position + 1 ENDGO Here is the result set: ----------- - 78 N ----------- - 101 e ----------- - 119 w ----------- - 32 ----------- - 77 M ----------- - 111 o ----------- - 111 o ----------- - 110 n ----------- - B. Use CHAR to insert a control character This example uses CHAR(13) to print name, address, and city information on separate lines. USE NorthwindSELECT FirstName + ' ' + LastName, + CHAR(13) + Address, + CHAR(13)+ City, Region FROM EmployeesWHERE EmployeeID = 1 Here is the result set:Nancy Davolio507 - 20th Ave. E.Apt. 2ASeattle WA
access "& 变量名 &" 字符型变量的引用 : '"& 变量名 &"'
日期型变量的引用 :sql_server '"& 变量名 &"'
access # "& 变量名 &"#
A string function that converts an int ASCII code to a character.Syntax
CHAR(integer_expression)Arguments
integer_expression
Is an integer from 0 through 255. NULL is returned if the integer expression is not in this range.
Return Types
char(1)Res
CHAR can be used to insert control characters into character strings. The table shows some commonly used control characters. Control character Value
Tab CHAR(9)
Line feed CHAR(10)
Carriage return CHAR(13)
Examples
A. Use ASCII and CHAR to print ASCII values from a string
This example prints the ASCII value and character for each character in the string New Moon.SET TEXTSIZE 0-- Create variables for the character string and for the current -- position in the string.DECLARE @position int, @string char(8)-- Initialize the current position and the string variables.SET @position = 1SET @string = 'New Moon'WHILE @position <= DATALENGTH(@string) BEGIN SELECT ASCII(SUBSTRING(@string, @position, 1)), CHAR(ASCII(SUBSTRING(@string, @position, 1))) SET @position = @position + 1 ENDGO Here is the result set: ----------- - 78 N ----------- - 101 e ----------- - 119 w ----------- - 32 ----------- - 77 M ----------- - 111 o ----------- - 111 o ----------- - 110 n ----------- - B. Use CHAR to insert a control character
This example uses CHAR(13) to print name, address, and city information on separate lines. USE NorthwindSELECT FirstName + ' ' + LastName, + CHAR(13) + Address,
+ CHAR(13)+ City, Region FROM EmployeesWHERE EmployeeID = 1 Here is the result set:Nancy Davolio507 - 20th Ave. E.Apt. 2ASeattle WA