SQL中没有这样的函数,要自己写.

解决方案 »

  1.   

    如果输入的是字符
    left(输入值,patindex('%*%',输入值)-1)
    如果输入的是数值,再转换一下
      

  2.   

    --测试
    --建测试表tb
    create table tb(filed varchar(10))
    insert into tb
    select '10*20' union all 
    select '100*200' union all 
    select '1000*2000'--查询
    select 输入的值=filed,你要的值=left(filed,charindex('*',filed)-1)
    from tb--删除测试表
    drop table tb--结果:输入的值       你要的值       
    ---------- ---------- 
    10*20      10
    100*200    100
    1000*2000  1000
      

  3.   

    select 输入的值=filed,你要的值=left(filed,charindex('*',filed)-1)
    from tb