一个汉字是不是占两个字符位置
-------------
一个汉字是一个“字符”,2个字节16位。
全角/半角都是一个字符。
加两个下划线就显示了刘晨和刘好东
-------------
不可能,1个下划线_表示任意一个字符,2个__则表示两个任意字符,所以不能显示刘晨。同时显示(不用%):
select name from student where name like '刘_' or name like '刘__'
如果只想要三个字的名字呢,而不显示两个汉字的
-------------
select name from student where name like '刘__'

解决方案 »

  1.   

    我就是 select name from student where name like '刘__' 那两人都显示出来了。
      

  2.   

     LEN
    返回给定字符串表达式的字符(而不是字节)个数,其中不包含尾随空格。语法
    LEN ( string_expression ) 
    要计算的字符串表达式。DATALENGTH 
    返回任何表达式所占用的字节数。语法
    DATALENGTH ( expression ) 
    以上两个函数是计算字符数/字节数
      

  3.   

    检查你的name 字段的数据类型是char还是varchar如果是前者,出来是对的。
      

  4.   

    楼主说的问题,测了一下不存在:
    declare @t table(Name nvarchar(10))
    insert @t select '刘晨'
    union select '刘好东'select * from @t where Name like '刘__'
    select * from @t where Name like '刘_'
    (所影响的行数为 2 行)Name       
    ---------- 
    刘好东(所影响的行数为 1 行)Name       
    ---------- 
    刘晨(所影响的行数为 1 行)
      

  5.   

    如上楼主所言:
    用char空格都会占一个字符
      

  6.   

    declare @t table(Name char(10))
    insert @t select '刘晨'
    union select '刘好东'select * from @t where Name like '刘__'   --显示2行
    select * from @t where Name like '刘_'    --显示1行
    这是因为你用了char类型
      

  7.   

    declare @t table(Name char(10))
    insert @t select '刘晨'
    union select '刘好东'select * from @t where Name like '刘__'   --显示2行
    select * from @t where Name like '刘_'    --显示1行
    这是因为你用了char类型
      

  8.   

    可能1: name -> char 或 nchar可能2: 刘晨后面有空格或其它不可视字符。输入时多敲了个空格,或者数据是从外部数据(比如Excel)导入的。