命名了带中划线的表明,简单的查询出错,换了名称就没有问题了

解决方案 »

  1.   


    if object_id('[tb-0]') is not null drop table [tb-0]
    go
    create table [tb-0] (zid int,data numeric(2,1))
    insert into [tb-0]
    select 1,0.5 union all
    select 2,1.0 union all
    select 3,1.5 union all
    select 4,3.5select * from [tb-0]
    zid         data
    ----------- ---------------------------------------
    1           0.5
    2           1.0
    3           1.5
    4           3.5(4 行受影响)
      

  2.   

    select * from 表 where 字段 like '%[-]%'
      

  3.   

    用分隔符,有2种方法 [] 或 ""1. [],在任何环境下都可用
    e.g:
      create table [s-s](id int)2. "",前提是SET QUOTED_IDENTIFIER ON
    e.g:
      create table "s-s"(id int)