if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[BankInfo]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[BankInfo]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[BankLog]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[BankLog]
GO

CREATE TABLE [dbo].[BankInfo] (
	[sID] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[nLine] [numeric](18, 0) NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[BankLog] (
	[nID] [int] IDENTITY (1, 1) NOT NULL ,
	[sID] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[dDate] [datetime] NULL ,
	[nVoucherID] [int] NULL ,
	[nEntryID] [int] NULL ,
	[sItemID] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[sTitle] [varchar] (254) COLLATE Chinese_PRC_CI_AS NULL ,
	[nInitMoney] [numeric](18, 4) NULL ,
	[nDeMoney] [numeric](18, 4) NULL ,
	[nLeMoney] [numeric](18, 4) NULL ,
	[nPrintTimes] [int] NULL ,
	[sComment] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[sUser] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[BankInfo] WITH NOCHECK ADD 
	CONSTRAINT [PK_BankInfo] PRIMARY KEY  CLUSTERED 
	(
		[sID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[BankLog] WITH NOCHECK ADD 
	CONSTRAINT [PK_BankLog] PRIMARY KEY  CLUSTERED 
	(
		[nID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[BankInfo] ADD 
	CONSTRAINT [DF_BankInfo_sID] DEFAULT ('') FOR [sID],
	CONSTRAINT [DF_BankInfo_nLine] DEFAULT (0) FOR [nLine]
GO

ALTER TABLE [dbo].[BankLog] ADD 
	CONSTRAINT [DF_BankLog_sID] DEFAULT (newid()) FOR [sID],
	CONSTRAINT [DF_BankLog_dDate] DEFAULT (getdate()) FOR [dDate],
	CONSTRAINT [DF_BankLog_sVouncherID] DEFAULT (0) FOR [nVoucherID],
	CONSTRAINT [DF_BankLog_sEntryID] DEFAULT (0) FOR [nEntryID],
	CONSTRAINT [DF_BankLog_sBatch] DEFAULT ('') FOR [sItemID],
	CONSTRAINT [DF_BankLog_sTitle] DEFAULT ('') FOR [sTitle],
	CONSTRAINT [DF_BankLog_nInitMoney] DEFAULT (0) FOR [nInitMoney],
	CONSTRAINT [DF_BankLog_nDeMoney] DEFAULT (0) FOR [nDeMoney],
	CONSTRAINT [DF_BankLog_nLeMoney] DEFAULT (0) FOR [nLeMoney],
	CONSTRAINT [DF_BankLog_nPrintTimes] DEFAULT (0) FOR [nPrintTimes],
	CONSTRAINT [DF_BankLog_sComment] DEFAULT ('') FOR [sComment],
	CONSTRAINT [DF_BankLog_sUser] DEFAULT ('') FOR [sUser]
GO


exec sp_addextendedproperty N'MS_Description', N'当前打印行,用来记录在存折上打印的当前行', N'user', N'dbo', N'table', N'BankInfo', N'column', N'nLine'
GO
exec sp_addextendedproperty N'MS_Description', N'账号ID，T_Account.ID', N'user', N'dbo', N'table', N'BankInfo', N'column', N'sID'


GO


exec sp_addextendedproperty N'MS_Description', N'打印日期', N'user', N'dbo', N'table', N'BankLog', N'column', N'dDate'
GO
exec sp_addextendedproperty N'MS_Description', N'借方额', N'user', N'dbo', N'table', N'BankLog', N'column', N'nDeMoney'
GO
exec sp_addextendedproperty N'MS_Description', N'凭证分录号,T_Vouncher.FEntryID', N'user', N'dbo', N'table', N'BankLog', N'column', N'nEntryID'
GO
exec sp_addextendedproperty N'MS_Description', N'原始金额', N'user', N'dbo', N'table', N'BankLog', N'column', N'nInitMoney'
GO
exec sp_addextendedproperty N'MS_Description', N'贷方额', N'user', N'dbo', N'table', N'BankLog', N'column', N'nLeMoney'
GO
exec sp_addextendedproperty N'MS_Description', N'打印次数', N'user', N'dbo', N'table', N'BankLog', N'column', N'nPrintTimes'
GO
exec sp_addextendedproperty N'MS_Description', N'凭证号,T_Vouncher.FVouncherID', N'user', N'dbo', N'table', N'BankLog', N'column', N'nVoucherID'
GO
exec sp_addextendedproperty N'MS_Description', N'备注', N'user', N'dbo', N'table', N'BankLog', N'column', N'sComment'
GO
exec sp_addextendedproperty N'MS_Description', N'取数据的批次号', N'user', N'dbo', N'table', N'BankLog', N'column', N'sID'
GO
exec sp_addextendedproperty N'MS_Description', N'账号ID', N'user', N'dbo', N'table', N'BankLog', N'column', N'sItemID'
GO
exec sp_addextendedproperty N'MS_Description', N'摘要', N'user', N'dbo', N'table', N'BankLog', N'column', N'sTitle'
GO
exec sp_addextendedproperty N'MS_Description', N'操作员', N'user', N'dbo', N'table', N'BankLog', N'column', N'sUser'


GO

