|
发表于 2013-4-16 14:23:50
|
显示全部楼层
下面的脚本到查询分析器执行一下。(先备份好数据)
use ufdata_008_2008 --打开年度数据库
--创建主表
CREATE TABLE [OM_PurBillVouch] (
[PBVID] [int] NOT NULL ,
[cPBVBillType] [varchar] (4) COLLATE Chinese_PRC_CI_AS NULL ,
[cPBVCode] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
[cPTCode] [varchar] (2) COLLATE Chinese_PRC_CI_AS NULL ,
[dPBVDate] [datetime] NOT NULL ,
[cVenCode] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cUnitCode] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
[cDepCode] [varchar] (12) COLLATE Chinese_PRC_CI_AS NULL ,
[cPersonCode] [varchar] (8) COLLATE Chinese_PRC_CI_AS NULL ,
[cPayCode] [varchar] (3) COLLATE Chinese_PRC_CI_AS NULL ,
[cexch_name] [varchar] (8) COLLATE Chinese_PRC_CI_AS NULL ,
[cExchRate] [float] NULL ,
[iPBVTaxRate] [float] NULL ,
[cPBVMemo] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
[cOrderCode] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
[cInCode] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
[cBusType] [varchar] (8) COLLATE Chinese_PRC_CI_AS NULL ,
[dSDate] [datetime] NULL ,
[cPBVMaker] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cPBVVerifier] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[bNegative] [bit] NOT NULL ,
[bOriginal] [bit] NOT NULL ,
[bFirst] [bit] NOT NULL ,
[citem_class] [varchar] (2) COLLATE Chinese_PRC_CI_AS NULL ,
[citemcode] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cHeadCode] [varchar] (15) COLLATE Chinese_PRC_CI_AS NULL ,
[iNetLock] [real] NULL ,
[cDefine1] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine2] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine3] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine4] [datetime] NULL ,
[cDefine5] [int] NULL ,
[cDefine6] [datetime] NULL ,
[cDefine7] [float] NULL ,
[cDefine8] [varchar] (4) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine9] [varchar] (8) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine10] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
[bPayment] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[dVouDate] [datetime] NULL ,
[iVTid] [int] NOT NULL CONSTRAINT [DF__OM_PurBillVo__iVTid__7193879D] DEFAULT (0),
[ufts] [timestamp] NULL ,
[cAccounter] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cSource] [varchar] (4) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine11] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine12] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine13] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine14] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine15] [int] NULL ,
[cDefine16] [float] NULL ,
[bIAFirst] [bit] NULL CONSTRAINT [DF__OM_purbillvo__bIAFi__7287ABD6] DEFAULT (0),
[YFID] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cAccountPID] [varchar] (3) COLLATE Chinese_PRC_CI_AS NULL ,
[cAccountPDate] [datetime] NULL ,
[iFPBalance] [bit] NULL ,
[cvenbank] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
[cvenaddress] [varchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
[cvenphone] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
[cvenfax] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cvenpostcode] [varchar] (6) COLLATE Chinese_PRC_CI_AS NULL ,
[cvenperson] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
[cvenaccount] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[cvenregcode] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
CONSTRAINT [OM_PurBillVouch_PK] PRIMARY KEY CLUSTERED
(
[PBVID]
) ON [PRIMARY] ,
FOREIGN KEY
(
[cDepCode]
) REFERENCES [Department] (
[cDepCode]
),
FOREIGN KEY
(
[cexch_name]
) REFERENCES [foreigncurrency] (
[cexch_name]
),
FOREIGN KEY
(
[cPayCode]
) REFERENCES [PayCondition] (
[cPayCode]
),
FOREIGN KEY
(
[cPersonCode]
) REFERENCES [Person] (
[cPersonCode]
),
FOREIGN KEY
(
[cPTCode]
) REFERENCES [PurchaseType] (
[cPTCode]
),
CONSTRAINT [FK__OM_PurBillVo__cVenC__617C500E] FOREIGN KEY
(
[cVenCode]
) REFERENCES [Vendor] (
[cVenCode]
)
) ON [PRIMARY]
GO
--创建子表
CREATE TABLE [OM_PurBillVouchs] (
[ID] [int] NOT NULL ,
[PBVID] [int] NOT NULL ,
[cInvCode] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[bExBill] [bit] NULL ,
[dInDate] [datetime] NULL ,
[iPBVQuantity] [float] NULL ,
[iNum] [float] NULL ,
[iOriCost] [float] NULL ,
[iOriMoney] [money] NULL ,
[iOriTaxPrice] [money] NULL ,
[iOriSum] [money] NULL ,
[iCost] [float] NULL ,
[iMoney] [money] NULL ,
[iTaxPrice] [money] NULL ,
[iSum] [money] NULL ,
[iExMoney] [money] NULL ,
[iLostQuan] [float] NULL ,
[iNLostQuan] [float] NULL ,
[iNLostMoney] [money] NULL ,
[iOriTotal] [money] NULL ,
[iTotal] [money] NULL ,
[cDebitHead] [varchar] (15) COLLATE Chinese_PRC_CI_AS NULL ,
[cTaxHead] [varchar] (15) COLLATE Chinese_PRC_CI_AS NULL ,
[cClue] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
[dSignDate] [datetime] NULL ,
[cCorInvCode] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cFree1] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cFree2] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[iTaxRate] [float] NULL ,
[cDefine22] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine23] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine24] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine25] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine26] [float] NULL CONSTRAINT [DF__OM_PurBillVo__cDefi__094028A5] DEFAULT (0),
[cDefine27] [float] NULL CONSTRAINT [DF__OM_PurBillVo__cDefi__0A344CDE] DEFAULT (0),
[iPOsID] [int] NULL CONSTRAINT [DF__OM_PurBillVo__iPOsI__090B1E7B] DEFAULT (null),
[cItemCode] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cItem_class] [varchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[cNLostType] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[mNLostTax] [money] NULL CONSTRAINT [DF__OM_PurBillVo__mNLos__147CD127] DEFAULT (0),
[cItemName] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
[cFree3] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cFree4] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cFree5] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cFree6] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cFree7] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cFree8] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cFree9] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[cFree10] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[dSDate] [datetime] NULL ,
[cUnitID] [varchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine28] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine29] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine30] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine31] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine32] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine33] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL ,
[cDefine34] [int] NULL ,
[cDefine35] [int] NULL ,
[cDefine36] [datetime] NULL ,
[cDefine37] [datetime] NULL ,
[iSBsID] [int] NULL ,
[RdsId] [int] NULL ,
[OMPOcCode] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
[OMRDcCode] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
[iOMmainID] [int] NULL ,
[iOMautoID] [int] NULL ,
[iYrkdAutoID] [int] NULL ,
[iYrkdID] [int] NULL ,
[cYrkdCode] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
[iBalance] [int] NULL ,
[csocode] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
[YCcode] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
[sosid] [int] NULL ,
[YCsid] [int] NULL ,
[iOriPrice] [float] NULL ,
[iPrice] [float] NULL ,
[croutsocode] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
[memo] [varchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
[opcode] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[opdes] [varchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
[opname] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[routdes] [varchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
[routcode] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[routmemo] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
[routname] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
[cOMcode] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
CONSTRAINT [PK_OM_Purbillvouchs] PRIMARY KEY CLUSTERED
(
[ID]
) ON [PRIMARY] ,
FOREIGN KEY
(
[cDebitHead]
) REFERENCES [code] (
[ccode]
),
FOREIGN KEY
(
[cInvCode]
) REFERENCES [Inventory] (
[cInvCode]
),
FOREIGN KEY
(
[cTaxHead]
) REFERENCES [code] (
[ccode]
),
CONSTRAINT [FK__OM_PurBillVo__PBVID] FOREIGN KEY
(
[PBVID]
) REFERENCES [OM_PurBillVouch] (
[PBVID]
)
) ON [PRIMARY]
GO
|
|