--V1.31所作升级
if exists( Select OptValue from tSysOpt where OptName='DBEdition')
begin
  Declare @DBVer varchar(10)
  Select @DBVer=OptValue from tSysOpt where OptName='DBEdition'
  Set @DBVer=Substring(@DBVer,1,4)+'-'+Substring(@DBVer,6,2)+'-'+Substring(@DBVer,9,2)
  if @DBVer>='2006-11-24'
    Return
end
--2006-11-20 批发客户表添加业务员字段
if not Exists(Select * from SysColumns where Id=Object_ID('tCustomer') and name='YWCode' )
begin
  alter table tCustomer add YWCode char(6)
  exec ('update tcustomer set YWCode='''' where YWCode is Null')
end
if not Exists(Select * from SysColumns where Id=Object_ID('tCustomer') and name='YWName' )
begin
  alter table tCustomer add YWName char(10) null
  exec ('update tcustomer set YWName='''' where YWName is Null')
end
--2006-11-21 批发客户表添加地区字段
if not Exists(Select * from SysColumns where Id=Object_ID('tCustomer') and name='AreaCode' )
begin
  alter table tCustomer add AreaCode char(6)
  exec ('update tcustomer set AreaCode='''' where AreaCode is Null')
end
if not Exists(Select * from SysColumns where Id=Object_ID('tCustomer') and name='AreaName' )
begin
  alter table tCustomer add AreaName char(20) null
  exec ('update tcustomer set AreaName='''' where AreaName is Null')
end