字段a什么类型?
如果是整数   0797当然=797了
如果是字符型
你查询:
select * from tablename where 字段a='0797'
select * from tablename where 字段a='797'
看看结果

解决方案 »

  1.   

    a是字符型
    我需要输入一条SQL语句!
      

  2.   

    declare @a char(50)
    select * from table where a = @a or a = right(@a,3)
      

  3.   

    Declare @test table (f_1 varchar(10))Insert @test values ('0799')
    Insert @test values('799')Declare @var intSet @var = 799
    Select * from @test where f_1 = @varSet @var = 0799
    Select * from @test where f_1 = @var-- 兩方法都可以
      

  4.   

    declare @a varchar(50)
    select @a='05201314'
    if left(@a,1)='c' set @a=substring(@a,2,len(@a)-1)
    select @a='%'+@a
    print @a
    select * from tabName where a like @a
      

  5.   

    declare @a varchar(50)
    select @a='05201314'
    if left(@a,1)='0' set @a=substring(@a,2,len(@a)-1)
    select @a='%'+@a
    print @a
    select * from tabName where a like @a