SELECT name FROM master.dbo.sysdatabases WHERE name = N'tttt'
'ttt'前面的N是什么意思啊??

解决方案 »

  1.   

    unicode字符   赋值的固定格式
    一般放在where部分,比如: 
    where   name   =   N 'ABC ' 
    就是如果你的name这个字段是nchar或者   nvarchar类型,必须前门加个N,这样才能获得正确的结果
      

  2.   

    unincode代码,防止字符串不匹配或变码.
      

  3.   

    NCHAR
    根据 Unicode 标准所进行的定义,用给定整数代码返回 Unicode 字符。语法
    NCHAR ( integer_expression ) 参数
    integer_expression介于 0 与 65535 之间的所有正整数。如果指定了超出此范围的值,将返回 NULL。返回类型
    nchar(1)示例
    A. 使用 NCHAR 和 UNICODE
    下面的示例使用 UNICODE 和 NCHAR 函数打印字符串 Køenhavn 第二个字符的 UNICODE 值和 NCHAR(Unicode 字符),并打印实际的第二个字符ø。DECLARE @nstring nchar(8)
    SET @nstring = N'København'
    SELECT UNICODE(SUBSTRING(@nstring, 2, 1)), 
       NCHAR(UNICODE(SUBSTRING(@nstring, 2, 1)))
    GO下面是结果集:----------- - 
    248         ø(1 row(s) affected)B. 使用 SUBSTRING、UNICODE、CONVERT 和 NCHAR
    下面的示例使用 SUBSTRING、UNICODE、CONVERT 和 NCHAR 函数打印字符串 Køenhavn 的字符数、Unicode 字符以及每个字符的 UNICODE 值。-- The @position variable holds the position of the character currently
    -- being processed. The @nstring variable is the Unicode character 
    -- string to process.
    DECLARE @position int, @nstring nchar(9)
    -- Initialize the current position variable to the first character in 
    -- the string.
    SET @position = 1
    -- Initialize the character string variable to the string to process.
    -- Notice that there is an N before the start of the string, which 
    -- indicates that the data following the N is Unicode data.
    SET @nstring = N'København'
    -- Print the character number of the position of the string you're at, 
    -- the actual Unicode character you're processing, and the UNICODE value -- for this particular character.
    PRINT 'Character #' + ' ' + 'Unicode Character' + ' ' + 'UNICODE Value'
    WHILE @position <= DATALENGTH(@nstring)
       BEGIN
       SELECT @position, 
          NCHAR(UNICODE(SUBSTRING(@nstring, @position, 1))),
          CONVERT(NCHAR(17), SUBSTRING(@nstring, @position, 1)),
          UNICODE(SUBSTRING(@nstring, @position, 1))
       SELECT @position = @position + 1
       END
    GO下面是结果集:Character # Unicode Character UNICODE Value
                                              
    ----------- ----------------- ----------- 
    1           K                 75          
                                              
    ----------- ----------------- ----------- 
    2           ø                 248         
                                              
    ----------- ----------------- ----------- 
    3           b                 98          
                                              
    ----------- ----------------- ----------- 
    4           e                 101         
                                              
    ----------- ----------------- ----------- 
    5           n                 110         
                                              
    ----------- ----------------- ----------- 
    6           h                 104         
                                              
    ----------- ----------------- ----------- 
    7           a                 97          
                                              
    ----------- ----------------- ----------- 
    8           v                 118         
                                              
    ----------- ----------------- ----------- 
    9           n                 110         
                                              
    ----------- ----------------- ----------- 
    10          (null)            (null)      
                                              
    ----------- ----------------- ----------- 
    11          (null)            (null)      
                                              
    ----------- ----------------- ----------- 
    12          (null)            (null)      
                                              
    ----------- ----------------- ----------- 
    13          (null)            (null)      
                                              
    ----------- ----------------- ----------- 
    14          (null)            (null)      
                                              
    ----------- ----------------- ----------- 
    15          (null)            (null)      
                                              
    ----------- ----------------- ----------- 
    16          (null)            (null)      
                                              
    ----------- ----------------- ----------- 
    17          (null)            (null)      
                                              
    ----------- ----------------- ----------- 
    18          (null)            (null)
      

  4.   

    http://topic.csdn.net/u/20101024/23/50a9baa1-47a9-41f5-9912-a5076d677d9c.html?3895此帖第8楼有关2005的部分,如果不使用nvarchar型,不在数据前加N,则会出现乱码.