use @DBNAME

if not exists (SELECT name       FROM      sysobjects       WHERE  name = N'webkartSetting'       AND      type = 'U')
begin 
begin tran createWebSetting
CREATE TABLE [dbo].[webkartSetting](
    [id] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY,
	[showBirthDate] [tinyint] NULL,
	[PwdLastChangeDate] [nvarchar](10) NULL,
	[SaveMissionTime] [tinyint] NULL,
	[showStatement] [tinyint] NULL,
	[shoEvents] [tinyint] NULL,
	[showCalandar] [tinyint] NULL,
	[adminUserName] [char](50) NULL,
	[adminPWD] [char](255) NULL,
	[defaultCityCode] [int] NULL,
	[defaultPermission] [char](100) NULL,
	[signCountforVacation] [int] NULL,
	[signCountforMission] [int] NULL,
	[signCountforIO] [int] NULL,
	[signCountforExtraWork] [int] NULL,
	[vacationPreDay] [int] NULL,
	[vacationEndDay] [int] NULL,
	[ioPreDay] [int] NULL,
	[ioEndDay] [int] NULL,
	[portalAccessUserName] [char](50) NULL,
	[portalAccessPassword] [char](50) NULL,
	[portalHomePage] [char](500) NULL,
	[portalErrorPage] [char](500) NULL,
	[LogOutMode] [tinyint] NULL,
	[ActiveDirectoryName] [char](200) NULL,
	[CanNotAddMorInHoliday] [tinyint] NULL,
	[CanNotAddMorAfterHoliday] [tinyint] NULL,
	[DisableMorLeft] [tinyint] NULL,
	[EnableAccessAfterDay] [int] NULL,
	[MaxMorInDay] [int] NULL,
	[MotavaliDay] [int] NULL,
	[MotanavebDay] [int] NULL,
	[limitOnVacation] [int] NULL,
	[MaxMorInPeriod] [int] NULL,
	[MaxIoRequestInPeriod] [int] NULL,
	[MissionPreDay] [int] NULL,
	[MissionNextDay] [int] NULL,
	[ExtraWorkPreDay] [int] NULL,
	[ExtraWorkNextDay] [int] NULL,
	[MaxVacation] [nvarchar](100) NULL,
	[AllowIoInCurrentDay] [int] NULL,
	[DeadLineConfirmMission] [int] NULL,
	[DeadLineConfirmVacation] [int] NULL,
	[DeadLineConfirmIo] [int] NULL,
	[DeadLineConfirmExtraWork] [int] NULL,
	[MisStatusAfterDeadLine] [int] NULL,
	[VacStatusAfterDeadLine] [int] NULL,
	[IoStatusAfterDeadLine] [int] NULL,
	[EwStatusAfterDeadLine] [int] NULL,
	[vacationUseWorkCalendar] [int] NULL,
	[clockEnabledInIO] [int] NULL,
	[MissionCount] [int] NULL,
	[VacationCount] [int] NULL,
	[IsEncrypted] [int] NULL,
	[IsCommentRequired] [int] NULL,
	[IsCommentRequiredForExtraWork] [int] NULL,
	[InBeginTimeVacation] [int] NULL,
	[TeloranceForBeginTimeVacation] [int] NULL,
    [InBeginTimeMission] [int] NULL,
	[TeloranceForBeginTimeMission] [int] NULL,
	[CheckIoForFirstTimeVacation] [int] NULL,
	[CheckIoForFirstTimeMission] [int] NULL,
	[LimitForOrdinaryVacation] [int] NULL,
	[LimitOnTimmingMissionLength] [int] NULL,
	[MaxMisInDay] [int] NULL,
	[MaxhourlyVacationPerYear] [float] not null default 0
) ON [PRIMARY]

if @@ERROR > 0 
  rollback tran createWebSetting    
commit 

end

else
begin

begin tran AlterNewwebSetting
if exists (SELECT name       FROM      sysobjects       WHERE  name = N'newwebSetting'       AND      type = 'U')	
 drop table newwebSetting
select * into newwebSetting  from  webkartSetting

drop table webkartSetting

CREATE TABLE [dbo].[webkartSetting](

    [id] [int] IDENTITY(1,1) not NULL PRIMARY KEY,
	[showBirthDate] [tinyint] NULL,
	[PwdLastChangeDate] [nvarchar](10) NULL,
	[SaveMissionTime] [tinyint] NULL,
	[showStatement] [tinyint] NULL,
	[shoEvents] [tinyint] NULL,
	[showCalandar] [tinyint] NULL,
	[adminUserName] [char](50) NULL,
	[adminPWD] [char](255) NULL,
	[defaultCityCode] [int] NULL,
	[defaultPermission] [char](100) NULL,
	[signCountforVacation] [int] NULL,
	[signCountforMission] [int] NULL,
	[signCountforIO] [int] NULL,
	[signCountforExtraWork] [int] NULL,
	[vacationPreDay] [int] NULL,
	[vacationEndDay] [int] NULL,
	[ioPreDay] [int] NULL,
	[ioEndDay] [int] NULL,
	[portalAccessUserName] [char](50) NULL,
	[portalAccessPassword] [char](50) NULL,
	[portalHomePage] [char](500) NULL,
	[portalErrorPage] [char](500) NULL,
	[LogOutMode] [tinyint] NULL,
	[ActiveDirectoryName] [char](200) NULL,
	[CanNotAddMorInHoliday] [tinyint] NULL,
	[CanNotAddMorAfterHoliday] [tinyint] NULL,
	[DisableMorLeft] [tinyint] NULL,
	[EnableAccessAfterDay] [int] NULL,
	[MaxMorInDay] [int] NULL,
	[MotavaliDay] [int] NULL,
	[MotanavebDay] [int] NULL,
	[limitOnVacation] [int] NULL,
	[MaxMorInPeriod] [int] NULL,
	[MaxIoRequestInPeriod] [int] NULL,
	[MissionPreDay] [int] NULL,
	[MissionNextDay] [int] NULL,
	[ExtraWorkPreDay] [int] NULL,
	[ExtraWorkNextDay] [int] NULL,
	[MaxVacation] [nvarchar](100) NULL,
	[AllowIoInCurrentDay] [int] NULL,
	[DeadLineConfirmMission] [int] NULL,
	[DeadLineConfirmVacation] [int] NULL,
	[DeadLineConfirmIo] [int] NULL,
	[DeadLineConfirmExtraWork] [int] NULL,
	[MisStatusAfterDeadLine] [int] NULL,
	[VacStatusAfterDeadLine] [int] NULL,
	[IoStatusAfterDeadLine] [int] NULL,
	[EwStatusAfterDeadLine] [int] NULL,
	[vacationUseWorkCalendar] [int] NULL,
	[clockEnabledInIO] [int] NULL,
    [MissionCount] [int] NULL,
	[VacationCount] [int] NULL,
    [IsEncrypted] [int] NULL,
    [IsCommentRequired] [int] NULL,
	[IsCommentRequiredForExtraWork] [int] NULL,
	[InBeginTimeVacation] [int] NULL,
	[TeloranceForBeginTimeVacation] [int] NULL,
	[InBeginTimeMission] [int] NULL,
	[TeloranceForBeginTimeMission] [int] NULL,
    [CheckIoForFirstTimeVacation] [int] NULL,
	[CheckIoForFirstTimeMission] [int] NULL,
	[LimitForOrdinaryVacation] [int] NULL,
	[LimitOnTimmingMissionLength] [int] NULL,
    [MaxMisInDay] [int] NULL,
	[MaxhourlyVacationPerYear] [float] not null default 0	

) ON
 [PRIMARY]

 EXECUTE (
' insert into webkartSetting ([showBirthDate],[showStatement],[shoEvents],[showCalandar],[adminUserName],[adminPWD],[defaultCityCode],[defaultPermission],[vacationPreDay],[vacationEndDay],[ioPreDay],[ioEndDay],[MaxhourlyVacationPerYear])
select [showBirthDate],[showStatement],[shoEvents],[showCalandar],[adminUserName],[adminPWD],[defaultCityCode],[defaultPermission],[vacationPreDay],[vacationEndDay],[ioPreDay],[ioEndDay],[MaxhourlyVacationPerYear] from  newwebSetting
 ')


IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'portalAccessUserName' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [portalAccessUserName] = (select [portalAccessUserName] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'defaultPermission' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [defaultPermission] = (select [defaultPermission] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'adminPWD' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [adminPWD] = (select [adminPWD] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'defaultCityCode' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [defaultCityCode] = (select [defaultCityCode] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'portalAccessPassword' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [portalAccessPassword] = (select [portalAccessPassword] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'clockEnabledInIO' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [clockEnabledInIO] = (select [clockEnabledInIO] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'SaveMissionTime' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [SaveMissionTime] = (select [SaveMissionTime] from  newwebSetting)
')
end




IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'DeadLineConfirmMission' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [DeadLineConfirmMission] = (select [DeadLineConfirmMission] from  newwebSetting)
update webkartSetting set [DeadLineConfirmVacation] = (select [DeadLineConfirmVacation] from  newwebSetting)
update webkartSetting set [DeadLineConfirmIo] = (select [DeadLineConfirmIo] from  newwebSetting)
update webkartSetting set [DeadLineConfirmExtraWork] = (select [DeadLineConfirmExtraWork] from  newwebSetting)
update webkartSetting set [MisStatusAfterDeadLine] = (select [MisStatusAfterDeadLine] from  newwebSetting)
update webkartSetting set [VacStatusAfterDeadLine] = (select [VacStatusAfterDeadLine] from  newwebSetting)
update webkartSetting set [IoStatusAfterDeadLine] = (select [IoStatusAfterDeadLine] from  newwebSetting)
update webkartSetting set [EwStatusAfterDeadLine] = (select [EwStatusAfterDeadLine] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'showBirthDate' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [showBirthDate] = (select [showBirthDate] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'PwdLastChangeDate' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [PwdLastChangeDate] = (select [PwdLastChangeDate] from  newwebSetting)
')
end


IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'showStatement' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [showStatement] = (select [showStatement] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'portalHomePage' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [portalHomePage] = (select [portalHomePage] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'portalErrorPage' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [portalErrorPage] = (select [portalErrorPage] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'LogOutMode' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [LogOutMode] = (select [LogOutMode] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'ActiveDirectoryName' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [ActiveDirectoryName] = (select [ActiveDirectoryName] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'adminUserName' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [adminUserName] = (select [adminUserName] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'shoEvents' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [shoEvents] = (select [shoEvents] from  newwebSetting)
update webkartSetting set [MaxVacation] = (select [MaxVacation] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'CanNotAddMorInHoliday' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [CanNotAddMorInHoliday] = (select [CanNotAddMorInHoliday] from  newwebSetting)
update webkartSetting set [CanNotAddMorAfterHoliday] = (select [CanNotAddMorAfterHoliday] from  newwebSetting)
update webkartSetting set [DisableMorLeft] = (select [DisableMorLeft] from  newwebSetting)
update webkartSetting set [EnableAccessAfterDay] = (select [EnableAccessAfterDay] from  newwebSetting)
update webkartSetting set [MaxMorInDay] = (select [MaxMorInDay] from  newwebSetting)
update webkartSetting set [MotavaliDay] = (select [MotavaliDay] from  newwebSetting)
update webkartSetting set [MotanavebDay] = (select [MotanavebDay] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'vacationPreDay' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [vacationPreDay] = (select [vacationPreDay] from  newwebSetting)
update webkartSetting set [vacationEndDay] = (select [vacationEndDay] from  newwebSetting)
update webkartSetting set [ioEndDay] = (select [ioEndDay] from  newwebSetting)
update webkartSetting set [EnableAccessAfterDay] = (select [EnableAccessAfterDay] from  newwebSetting)
')
end


IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'limitOnVacation' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [limitOnVacation] = (select [limitOnVacation] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'vacationUseWorkCalendar' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [vacationUseWorkCalendar] = (select [vacationUseWorkCalendar] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'AllowIoInCurrentDay' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [AllowIoInCurrentDay] = (select [AllowIoInCurrentDay] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'MaxMorInPeriod' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [MaxMorInPeriod] = (select [MaxMorInPeriod] from  newwebSetting)
update webkartSetting set [MaxIoRequestInPeriod] = (select [MaxIoRequestInPeriod] from  newwebSetting)
')
end




IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'MissionPreDay' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [MissionPreDay] = (select [MissionPreDay] from  newwebSetting)
update webkartSetting set [MissionNextDay] = (select [MissionNextDay] from  newwebSetting)
update webkartSetting set [ExtraWorkPreDay] = (select [ExtraWorkPreDay] from  newwebSetting)
update webkartSetting set [ExtraWorkNextDay] = (select [ExtraWorkNextDay] from  newwebSetting)
')
end



If Not Exists(SELECT     id
                FROM         syscolumns
                WHERE     (name = 'clockEnabledInIO') AND (id = OBJECT_ID(N'webkartSetting'))) 
Begin
    ALTER TABLE dbo.webkartSetting ADD clockEnabledInIO int NULL

    Execute sp_ExecuteSQL N'UPDATE webkartSetting SET clockEnabledInIO = 0'
End

If Not Exists(SELECT     id
                FROM         syscolumns
                WHERE     (name = 'vacationUseWorkCalendar') AND (id = OBJECT_ID(N'webkartSetting'))) 
Begin
    ALTER TABLE dbo.webkartSetting ADD vacationUseWorkCalendar int NULL

    Execute sp_ExecuteSQL N'UPDATE webkartSetting SET vacationUseWorkCalendar = 0'
End

If Not Exists(SELECT     id
                FROM         syscolumns
                WHERE     (name = 'MaxVacation') AND (id = OBJECT_ID(N'webkartSetting'))) 
Begin
    ALTER TABLE dbo.webkartSetting ADD MaxVacation nvarchar(100) NULL

    Execute sp_ExecuteSQL N'UPDATE webkartSetting SET MaxVacation = 0'
End

If Not Exists(SELECT     id
                FROM         syscolumns
                WHERE     (name = 'AllowIoInCurrentDay') AND (id = OBJECT_ID(N'webkartSetting'))) 
Begin
    ALTER TABLE dbo.webkartSetting ADD AllowIoInCurrentDay int NULL

    Execute sp_ExecuteSQL N'UPDATE webkartSetting SET AllowIoInCurrentDay = 0'
End



IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'limitOnVacation' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [limitOnVacation] = (select [limitOnVacation] from  newwebSetting)
')
end


 

 If(Exists(SELECT     id
                FROM         syscolumns
                WHERE     (name = 'SaveMissionTime') AND (id IN
                                          (SELECT     id
                                             FROM         sysobjects
                                             WHERE     (name = 'webkartSetting')))))
Execute sp_ExecuteSQL N'UPDATE webkartSetting SET SaveMissionTime = 1 WHERE SaveMissionTime is NULL'


 If(Exists(SELECT     id
                FROM         syscolumns
                WHERE     (name = 'SaveMissionTime') AND (id IN
                                          (SELECT     id
                                             FROM         sysobjects
                                             WHERE     (name = 'webkartSetting')))))
Execute sp_ExecuteSQL N'UPDATE webkartSetting SET SaveMissionTime = 1 WHERE SaveMissionTime is NULL'

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'MissionCount' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [MissionCount] = (select [MissionCount] from  newwebSetting)
')
end


IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'VacationCount' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [VacationCount] = (select [VacationCount] from  newwebSetting)
')
end


IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'IsCommentRequired' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [IsCommentRequired] = (select [IsCommentRequired] from  newwebSetting)
')
end


If(Exists(SELECT     id
                FROM         syscolumns
                WHERE     (name = 'IsCommentRequired') AND (id IN
                                          (SELECT     id
                                             FROM         sysobjects
                                             WHERE     (name = 'webkartSetting')))))
Execute sp_ExecuteSQL N'UPDATE webkartSetting SET IsCommentRequired = 0 WHERE IsCommentRequired is NULL'

--added by wria on 13960830
IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'IsCommentRequiredForExtraWork' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [IsCommentRequiredForExtraWork] = (select [IsCommentRequiredForExtraWork] from  newwebSetting)
')
end


If(Exists(SELECT     id
                FROM         syscolumns
                WHERE     (name = 'IsCommentRequiredForExtraWork') AND (id IN
                                          (SELECT     id
                                             FROM         sysobjects
                                             WHERE     (name = 'webkartSetting')))))
Execute sp_ExecuteSQL N'UPDATE webkartSetting SET IsCommentRequiredForExtraWork = 0 WHERE IsCommentRequiredForExtraWork is NULL'




IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'InBeginTimeVacation' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [InBeginTimeVacation] = (select [InBeginTimeVacation] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'TeloranceForBeginTimeVacation' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [TeloranceForBeginTimeVacation] = (select [TeloranceForBeginTimeVacation] from  newwebSetting)
')
end


IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'InBeginTimeMission' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [InBeginTimeMission] = (select [InBeginTimeMission] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'TeloranceForBeginTimeMission' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [TeloranceForBeginTimeMission] = (select [TeloranceForBeginTimeMission] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'CheckIoForFirstTimeVacation' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [CheckIoForFirstTimeVacation] = (select [CheckIoForFirstTimeVacation] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'CheckIoForFirstTimeMission' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [CheckIoForFirstTimeMission] = (select [CheckIoForFirstTimeMission] from  newwebSetting)
')
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'LimitForOrdinaryVacation' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [LimitForOrdinaryVacation] = (select [LimitForOrdinaryVacation] from  newwebSetting)
')
end


IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'LimitOnTimmingMissionLength' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [LimitOnTimmingMissionLength] = (select [LimitOnTimmingMissionLength] from  newwebSetting)
')
end


 IF(Exists(SELECT     id
                FROM         syscolumns
                WHERE     (name = 'IsEncrypted') AND (id IN
                                          (SELECT     id
                                             FROM         sysobjects
                                             WHERE     (name = 'newwebSetting')))))

											 begin
EXECUTE ('
update webkartSetting set [IsEncrypted] = (select [IsEncrypted] from  newwebSetting)
')
end

IF EXISTS(SELECT * FROM syscolumns WHERE     name = 'MaxMisInDay' AND id = object_Id(N'newwebSetting')) 
begin
EXECUTE ('
update webkartSetting set [MaxMisInDay] = (select [MaxMisInDay] from  newwebSetting)
')
end

if @@ERROR > 0 
  rollback tran AlterNewwebSetting    
commit 
end

if exists (SELECT name       FROM      sysobjects       WHERE  name = N'newwebSetting'       AND      type = 'U')	
 drop table newwebSetting
declare @adminusername char(50)
set @adminusername = (SELECT     adminUserName FROM         webkartSetting)
if(@adminusername is NULL)
    insert into webkartSetting  (adminUserName, adminPWD, defaultCityCode)
values ('Admin','.',1)


---begin add PassChangePerDayCount---
	begin tran updateWebKartSetting
	IF NOT EXISTS(SELECT * FROM sys.columns 
				WHERE Name = N'PassChangePerDayCount' AND Object_ID = Object_ID(N'WebKartSetting'))
	Begin
		ALTER TABLE dbo.WebKartSetting ADD
				PassChangePerDayCount numeric(6, 0) not null default 0
	End

	if @@ERROR > 0 
	  rollback tran updateWebKartSetting
	commit 
---end add PassChangePerDayCount--


---begin add PassChangePerDayCount---
	begin tran updateWebKartSetting
	IF NOT EXISTS(SELECT * FROM sys.columns 
				WHERE Name = N'MaxhourlyVacationPerYear' AND Object_ID = Object_ID(N'WebKartSetting'))
	Begin
		ALTER TABLE dbo.WebKartSetting ADD
				MaxhourlyVacationPerYear float not null default 0
	End

	if @@ERROR > 0 
	  rollback tran updateWebKartSetting
	commit 
---end add PassChangePerDayCount--
update WebKartSetting set PwdLastChangeDate = '13' +  PwdLastChangeDate 
where Len(PwdLastChangeDate) <= 8