⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dstr_fd.sql

📁 用友U8财务软件VB源程序, 本版本为2002年版本
💻 SQL
📖 第 1 页 / 共 5 页
字号:
            and   indid > 0
            and   indid < 255)
   drop index fd_accunit.ix_fd_accunit_type_code
go


if exists (select 1
            from  sysindexes
           where  id    = object_id('fd_accunit')
            and   name  = 'ix_fd_accunit_code'
            and   indid > 0
            and   indid < 255)
   drop index fd_accunit.ix_fd_accunit_code
go


if exists (select 1 from sysobjects where id = object_id('fd_accunit') and type = 'U') and COLUMNPROPERTY( OBJECT_ID('fd_accunit'),'accunit_id','AllowsNull') is null
	begin
	IF EXISTS (SELECT name FROM sysobjects  WHERE name = 'AddDateDfltaccunit' AND type = 'D')
	begin
	exec sp_unbindefault 'fd_accunit.accunit_id'
	drop default AddDateDfltaccunit
	end
	alter table fd_accunit add accunit_id fd_udt_id not null constraint AddDateDfltaccunit DEFAULT '000000000000000'
	alter table fd_accunit drop constraint AddDateDfltaccunit
	end
go


if exists (select 1 from sysobjects where id = object_id('fd_accunit') and type = 'U') and COLUMNPROPERTY( OBJECT_ID('fd_accunit'),'accunit_id','AllowsNull') = 0
	if exists (select 1 from fd_accunit where accunit_id = '000000000000000')
	begin
	update fd_accunit set accunit_id =890000000000000 + iid
	update fd_accunit set accunit_id =stuff(accunit_id,1,1,'0')
	end
go


if exists (select 1 from sysobjects where id = object_id('fd_accunit') and type = 'U') and COL_LENGTH('fd_accunit','cUnitCode') < 50
	begin
	alter table fd_accunit drop constraint aaaaaFD_AccUnit_PK
	alter table fd_accunit alter column cUnitCode nvarchar(50) not null
	end
go


if exists (select 1 from sysobjects where id = object_id('fd_accunit') and type = 'U') and COL_LENGTH('fd_accunit','cUnitName') < 80
	begin
	drop index fd_accunit.Cunitname
	alter table fd_accunit alter column cUnitName nvarchar(80) not null
	end
go


if exists (select 1 from sysobjects where id = object_id('fd_accunit') and type = 'U') and COL_LENGTH('fd_accunit','cMark') < 80
	begin
	IF EXISTS (SELECT name FROM sysobjects  WHERE name = 'FD_AccUnit_cMark_D' AND type = 'D')
	begin
	exec sp_unbindefault 'fd_accunit.cMark'
	drop default FD_AccUnit_cMark_D
	end
	alter table fd_accunit alter column cMark fd_udt_digest null
	end
go


if exists (select 1 from sysobjects where id = object_id('fd_accunit') and type = 'U') and COLUMNPROPERTY( OBJECT_ID('fd_accunit'),'accunit_id','AllowsNull') = 0 and not exists (select 1 from  sysindexes where  id    = object_id('fd_accunit') and  name  = 'PK_FD_ACCUNIT' and   indid > 0   and   indid < 255)
	alter table fd_accunit add constraint PK_FD_ACCUNIT primary key ([accunit_id]) on 'default'
go


if not exists (select 1 from  sysobjects where  id = object_id('fd_accunit') and type = 'U')
	create table fd_accunit (
	accunit_id           fd_udt_id            not null,
	CUnitCode            nvarchar(50)         not null,
	CUnitName            nvarchar(80)         not null,
	Cmark                fd_udt_digest        null,
	Itype                tinyint              not null,
	constraint PK_FD_ACCUNIT primary key  (accunit_id)
	)
go


create unique  index ix_fd_accunit_id on fd_accunit (
Itype,
accunit_id
)
go


create index ix_fd_accunit_name on fd_accunit (
CUnitName
)
go


create unique  index ix_fd_accunit_type_code on fd_accunit (
Itype,
CUnitCode
)
go


create unique  index ix_fd_accunit_code on fd_accunit (
CUnitCode
)
go


if exists (select 1
            from  sysindexes
           where  id    = object_id('fd_accdef')
            and   name  = 'ix_fd_accdef_code'
            and   indid > 0
            and   indid < 255)
   drop index fd_accdef.ix_fd_accdef_code
go


if exists (select 1
            from  sysindexes
           where  id    = object_id('fd_accdef')
            and   name  = 'ix_fd_accdef_cad'
            and   indid > 0
            and   indid < 255)
   drop index fd_accdef.ix_fd_accdef_cad
go


if exists (select 1
            from  sysindexes
           where  id    = object_id('fd_accdef')
            and   name  = 'ix_fd_accdef_irate'
            and   indid > 0
            and   indid < 255)
   drop index fd_accdef.ix_fd_accdef_irate
go


if exists (select 1
            from  sysindexes
           where  id    = object_id('fd_accdef')
            and   name  = 'ix_fd_accdef_unit'
            and   indid > 0
            and   indid < 255)
   drop index fd_accdef.ix_fd_accdef_unit
go


if exists (select 1
            from  sysindexes
           where  id    = object_id('fd_accdef')
            and   name  = 'ix_fd_accdef_datasrc'
            and   indid > 0
            and   indid < 255)
   drop index fd_accdef.ix_fd_accdef_datasrc
go


if exists (select 1 from sysobjects where id = object_id('fd_accdef') and type = 'U')
	begin
		if COLUMNPROPERTY( OBJECT_ID('fd_accdef'),'cAccBank','AllowsNull') is null
		alter table fd_accdef add cAccBank nvarchar(100) null
	end
go


if exists (select 1 from sysobjects where id = object_id('fd_accdef') and type = 'U') and COLUMNPROPERTY( OBJECT_ID('fd_accdef'),'accdef_id','AllowsNull') is null
	begin
	IF EXISTS (SELECT name FROM sysobjects  WHERE name = 'AddDateDfltaccdef' AND type = 'D')
	begin
	exec sp_unbindefault 'fd_accdef.accdef_id'
	drop default AddDateDfltaccdef
	end
	alter table fd_accdef add accdef_id fd_udt_id not null constraint AddDateDfltaccdef DEFAULT '000000000000000'	
	alter table fd_accdef drop constraint AddDateDfltaccdef
	IF EXISTS (SELECT name FROM sysobjects  WHERE name = 'AddDateDfltaccunit_id' AND type = 'D')
	begin
	exec sp_unbindefault 'fd_accdef.accunit_id'
	drop default AddDateDfltaccunit_id
	end
	alter table fd_accdef add accunit_id fd_udt_id not null constraint AddDateDfltaccunit_id DEFAULT '000000000000000'	
	alter table fd_accdef drop constraint AddDateDfltaccunit_id
	IF EXISTS (SELECT name FROM sysobjects  WHERE name = 'AddDateDfltaccirate_id' AND type = 'D')
	begin
	exec sp_unbindefault 'fd_accdef.irate_id'
	drop default AddDateDfltaccirate_id
	end
	alter table fd_accdef add irate_id fd_udt_id not null constraint AddDateDfltaccirate_id DEFAULT '000000000000000'	
	alter table fd_accdef drop constraint AddDateDfltaccirate_id
	IF EXISTS (SELECT name FROM sysobjects  WHERE name = 'AddDateDfltacccad_id' AND type = 'D')
	begin
	exec sp_unbindefault 'fd_accdef.cad_id'
	drop default AddDateDfltacccad_id
	end
	alter table fd_accdef add cad_id fd_udt_id null constraint AddDateDfltacccad_id DEFAULT '000000000000000'	
	alter table fd_accdef drop constraint AddDateDfltacccad_id
	IF EXISTS (SELECT name FROM sysobjects  WHERE name = 'AddDateDfltaccytcad_id' AND type = 'D')
	begin
	exec sp_unbindefault 'fd_accdef.yt_cad_id'
	drop default AddDateDfltaccytcad_id
	end
	alter table fd_accdef add yt_cad_id fd_udt_id null constraint AddDateDfltaccytcad_id DEFAULT '000000000000000'	
	alter table fd_accdef drop constraint AddDateDfltaccytcad_id
	end
go


if exists (select 1 from sysobjects where id = object_id('fd_accdef') and type = 'U') and COLUMNPROPERTY( OBJECT_ID('fd_accdef'),'accdef_id','AllowsNull') = 0
	if exists (select 1 from fd_accdef where accdef_id = '000000000000000')
	begin
	update fd_accdef set accdef_id =910000000000000 + iid
	update fd_accdef set accdef_id =stuff(accdef_id,1,1,'0')
	end
go


if exists (select 1 from sysobjects where id = object_id('fd_accdef') and type = 'U') and COLUMNPROPERTY( OBJECT_ID('fd_accdef'),'accunit_id','AllowsNull') = 0
	if exists (select 1 from fd_accdef where accunit_id = '000000000000000')
	begin
	update fd_accdef set accunit_id =fd_accunit.accunit_id from fd_accdef,fd_accunit where fd_accdef.CUnitCode=fd_accunit.CUnitCode
	end	
go


if exists (select 1 from sysobjects where id = object_id('fd_accdef') and type = 'U') and COLUMNPROPERTY( OBJECT_ID('fd_accdef'),'irate_id','AllowsNull') = 0
	if exists (select 1 from fd_accdef where irate_id = '000000000000000')
	begin
	update fd_accdef set irate_id =fd_intra.irate_id from fd_accdef,fd_intra where fd_accdef.cIntrID=fd_intra.cIntrID
	end	
go


if exists (select 1 from sysobjects where id = object_id('fd_accdef') and type = 'U') and COLUMNPROPERTY( OBJECT_ID('fd_accdef'),'cad_id','AllowsNull') = 0
	if exists (select 1 from fd_accdef where cad_id = '000000000000000')
	begin
	update fd_accdef set cad_id =fd_cadset.cad_id from fd_accdef,fd_cadset where fd_accdef.cCadID=fd_cadset.cCadID
	end
go


if exists (select 1 from sysobjects where id = object_id('fd_accdef') and type = 'U')
	begin
		if COLUMNPROPERTY( OBJECT_ID('fd_accdef'),'iYt','AllowsNull') is null
		alter table fd_accdef add iYt bit null
		if COLUMNPROPERTY( OBJECT_ID('fd_accdef'),'cYtID','AllowsNull') is null
		alter table fd_accdef add cYtID nvarchar(50) null
		else
		alter table fd_accdef alter column cYtID nvarchar(50) null
	end
go


if exists (select 1 from sysobjects where id = object_id('fd_accdef') and type = 'U') and COLUMNPROPERTY( OBJECT_ID('fd_accdef'),'yt_cad_id','AllowsNull') = 0
	if exists (select 1 from fd_accdef where yt_cad_id = '000000000000000')
	begin
	update fd_accdef set yt_cad_id =fd_cadset.cad_id from fd_accdef,fd_cadset where fd_accdef.cYtID=fd_cadset.cCadID
	end
go


if exists (select 1 from sysobjects where id = object_id('fd_accdef') and type = 'U') and COL_LENGTH('fd_accdef','CAccID') < 50
	begin
	drop index fd_accdef.cacc_id
	alter table fd_accdef drop constraint aaaaaFD_AccDef_PK
	alter table fd_accdef alter column CAccID nvarchar(50) null
	end
go


if exists (select 1
            from  sysindexes
           where  id    = object_id('fd_accdef')
            and   name  = '{4A800869-B115-11D2-9D4D-0000210020FA}'
            and   indid > 0
            and   indid < 255)
   drop index fd_accdef.[{4A800869-B115-11D2-9D4D-0000210020FA}]
go


if exists (select 1
            from  sysindexes
           where  id    = object_id('fd_accdef')
            and   name  = 'cUnitCode'
            and   indid > 0
            and   indid < 255)
   drop index fd_accdef.cUnitCode
go


if exists (select 1
            from  sysindexes
           where  id    = object_id('fd_accdef')
            and   name  = 'iDataSrc'
            and   indid > 0
            and   indid < 255)
   drop index fd_accdef.iDataSrc
go


if exists (select 1
            from  sysindexes
           where  id    = object_id('fd_accdef')
            and   name  = 'FD_AccUnitFD_AccDef'
            and   indid > 0
            and   indid < 255)
   drop index fd_accdef.FD_AccUnitFD_AccDef
go


if exists (select 1 from sysobjects where id = object_id('fd_accdef') and type = 'U') and COL_LENGTH('fd_accdef','cUnitCode') < 50
	begin
	alter table fd_accdef alter column cUnitCode nvarchar(50) null
	end
go


if exists (select 1 from sysobjects where id = object_id('fd_accdef') and type = 'U') and COL_LENGTH('fd_accdef','cIntrID') < 50
	begin
	drop index fd_accdef.cIntrID
	alter table fd_accdef alter column cIntrID nvarchar(50) null
	end
go


if exists (select 1 from sysobjects where id = object_id('fd_accdef') and type = 'U') and COL_LENGTH('fd_accdef','cCadID') < 50
	begin
	drop index fd_accdef.cCadID
	alter table fd_accdef alter column cCadID nvarchar(50) null
	end
go

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -