123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- if not exists(select * from dbo.sysobjects where id = object_id(N'CatalogInfo') and objectproperty(id,'IsTable') = 1)
- begin
- create table [dbo].[CatalogInfo](
- [enable] [bit] default(1) not null,
- [branch] [nvarchar](24) not null,
- [branchid] [nvarchar](32) not null,
- [clgname] [nvarchar](24) not null,
- [clgport] [int] default(0) null,
- [clgsource] [nvarchar](24) not null,
- [clgaccount] [nvarchar](24) not null,
- [clgpassword] [nvarchar](16) not null,
-
-
- constraint [PK_CatalogInfo] primary key clustered
- (
- [branchid] asc
- ) with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on,allow_page_locks = on) on [primary],
- ) on [primary]
- end
- go
- if not exists(select * from dbo.sysobjects where id = object_id(N'IncrementalBackup') and objectproperty(id,'IsTable') = 1)
- begin
- create table [dbo].[IncrementalBackup](
- [isbackup] [bit] default(0) not null,
- [branchid] [nvarchar](32) not null,
- [opttime] datetime default(getdate()),
- [order] [nvarchar](32) not null,
- [photoType] [tinyint] default(0) not null,
- [content] [nvarchar](max) null,
- [userid] [nvarchar](64) not null,
- [username] [nvarchar](16) not null,
- [baktime] datetime null,
-
- constraint [PK_IncrementBackup] primary key clustered
- (
- [branchid] asc,
- [order] asc,
- [opttime] asc
- )with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on,allow_page_locks = on) on [primary],
- ) on [primary]
- end
- go
- if not exists(select * from dbo.sysobjects where id = object_id(N'NetShareInfo') and objectproperty(id,'IsTable') = 1)
- begin
- create table [dbo].[NetShareInfo](
- [enable] [bit] default(1) not null,
- [branchid] [nvarchar](32) not null,
- [sharePath] [nvarchar](64) not null,
- [mincapacity] [tinyint] default(5) not null,
- [maxcapacity] [tinyint] default(35) not null,
- [photoType] [tinyint] not null,
- [priority] [tinyint] default(1) not null,
-
- constraint [PK_NetShareInfo] primary key clustered
- (
-
- [sharePath] asc
- ) with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on,allow_page_locks = on) on [primary],
- ) on [primary]
- end
- go
- alter table [dbo].[NetShareInfo] with check add check([mincapacity] >= 5)
- alter table [dbo].[NetShareInfo] with check add check([maxcapacity] >= 35)
- go
- alter table [dbo].[NetShareInfo] with check add check([priority] >= 1)
- go
- if (object_id('tgr_photomanager_insert','tr') is not null)
- drop trigger tgr_photomanager_insert
- go
- create trigger tgr_photomanager_insert on dindan for insert
- as
- begin transaction
- declare @branchid nvarchar(32)
- declare @order nvarchar(24)
- declare @status nvarchar(8)
-
- select top 1 @branchid = path1 from [path]
-
- select @order = id, @status = status3 from inserted
- if ( @status = 'OK')
- insert into [dbo].[photoManager]([branchid],[order],[takestatus])values(@branchid,@order,1)
- else
- insert into [dbo].[photoManager]([branchid],[order],[takestatus])values(@branchid,@order,0)
- commit transaction
- go
- if (object_id('tgr_photomanager_update','tr') is not null)
- drop trigger tgr_photomanager_update
- go
- create trigger tgr_photomanager_update on dindan for update
- as
- begin transaction
- declare @branchid nvarchar(32)
- declare @order nvarchar(24)
- declare @status nvarchar(8)
- declare @stime nvarchar(24)
- declare @count int
-
- select top 1 @branchid = path1 from [path]
-
- select @order = id, @status = status3, @stime = time5 from inserted
- select @count=count(*) from photomanager where [order] = @order
- if ( @status = 'OK' and @count > 0 )
- update [photoManager] set [takestatus] = 1,[taketime] = @stime where [order] = @order
- else if ( @status <> 'OK' and @count > 0 )
- update [photoManager] set [takestatus] = 0,[taketime] = @stime where [order] = @order
- else if ( @status = 'OK' and @count = 0 )
- insert into [photoManager]([branchid],[order],[takestatus],[taketime])values(@branchid,@order,1,@stime)
- else if ( @status <> 'OK' and @count = 0 )
- insert into [photoManager]([branchid],[order],[takestatus])values(@branchid,@order,0)
- commit transaction
- go
- if not exists(select * from dbo.sysobjects where id = object_id(N'PhotoManager') and objectproperty(id,'IsTable') = 1)
- begin
- create table [dbo].[PhotoManager](
- [branchid] [nvarchar](32) not null,
- [order] [nvarchar](24) not null,
- [takestatus] [bit] default(0) not null,
- [taketime] [nvarchar](24) null,
- [opdel] [bit] default(0) not null,
- [epdel] [bit] default(0) not null,
- [fpdel] [bit] default(0) not null,
- [dpdel] [bit] default(0) not null,
- [opbdel] [bit] default(0) not null,
- [epbdel] [bit] default(0) not null,
- [fpbdel] [bit] default(0) not null,
- [dpbdel] [bit] default(0) not null,
- [opdeltm] [nvarchar](24) null,
- [epdeltm] [nvarchar](24) null,
- [fpdeltm] [nvarchar](24) null,
- [dpdeltm] [nvarchar](24) null,
- [opbdeltm] [nvarchar](24) null,
- [epbdeltm] [nvarchar](24) null,
- [fpbdeltm] [nvarchar](24) null,
- [dpbdeltm] [nvarchar](24) null,
-
- constraint [PK_PhotoManager] primary key clustered
- (
- [branchid] asc,
- [order] asc
- ) with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on,allow_page_locks = on) on [primary],
- ) on [primary]
- end
- go
- select identity(int,1,1) as autoid, id, VisitTime8 into
- declare @maxid int
- declare @id nvarchar(50)
- declare @v8 nvarchar(20)
- select @maxid = max(autoid) from
- while @maxid > 0
- begin
- select @id = id, @v8 = VisitTime8 from
- update dindan set VisitTime8 = VisitTime8 where id = @id
- set @maxid = @maxid -1
- end
- drop table
|