不好意思完整的是这样。
IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS
      WHERE TABLE_NAME = 'pzview1')
   DROP VIEW pzview1
GO
create view pzview1 as SELECT Sum(md) As JJe, Sum(mc) As DJe,iperiod, isignseq, ino_id  FROM GL_accvouch 
WHERE (1=1 and GL_accvouch.iperiod >=1 and GL_accvouch.iperiod <=12) GROUP BY iperiod,isignseq,ino_id

解决方案 »

  1.   

    1=1是为了方便组合SQL 语句用的,如果没有它,你就要自己判断有多少个条件,中间用N-1个AND,有了1=1,你就可以写
    @wherestr = "1=1"
    set @wherestr = @wherestr + " and xxx=@xxx"
    set @wherestr = @wherestr + " and xxx=@xxx"
    set @wherestr = @wherestr + " and xxx=@xxx"
      

  2.   

    1=1的作用是:如果你用一个固定的模式 'and 条件'
    那么如果没有1=1,就会有错误。
    1=1 and 条件
      

  3.   

    1=1 任何情况为TRUE值,不影响查询的条件,一般用于方便查询三个表连接的例子如下:
    select a.* from a left join b on a.编号 = b.编号 left join c on a.编号 = c.编号