CREATE TABLE [dbo].[Information_UrgeReport]( [UrgeReportId] [nvarchar](50) NOT NULL, [UnitId] [nvarchar](50) NULL, [ReprotType] [nvarchar](50) NULL, [YearId] [nvarchar](50) NULL, [MonthId] [nvarchar](50) NULL, [QuarterId] [nvarchar](50) NULL, [HalfYearId] [nvarchar](50) NULL, [UrgeDate] [datetime] NULL, [IsComplete] [bit] NULL, [IsCancel] [bit] NULL, CONSTRAINT [PK_Information_UrgeReport] PRIMARY KEY CLUSTERED ( [UrgeReportId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO ALTER TABLE [dbo].[Information_UrgeReport] WITH CHECK ADD CONSTRAINT [FK_Information_UrgeReport_Base_Unit] FOREIGN KEY([UnitId]) REFERENCES [dbo].[Base_Unit] ([UnitId]) GO ALTER TABLE [dbo].[Information_UrgeReport] CHECK CONSTRAINT [FK_Information_UrgeReport_Base_Unit] GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'催报id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Information_UrgeReport', @level2type=N'COLUMN',@level2name=N'UrgeReportId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单位id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Information_UrgeReport', @level2type=N'COLUMN',@level2name=N'UnitId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N' 报表类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Information_UrgeReport', @level2type=N'COLUMN',@level2name=N'ReprotType' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否上报' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Information_UrgeReport', @level2type=N'COLUMN',@level2name=N'IsComplete' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'安全信息催报表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Information_UrgeReport' GO CREATE VIEW [dbo].[View_Supervise_SubUnitReportItem] AS /*子公司安全上报*/ SELECT Item.SubUnitReportItemId, Item.SubUnitReportId, Item.UnitId, Item.PlanReortDate, Item.ReportTitle, Item.ReportContent, --Item.AttachUrl, Item.ReportDate, Item.State, Item.UpState, SUBSTRING(AttachFile.AttachUrl,CHARINDEX('~',AttachFile.AttachUrl)+1,LEN(AttachFile.AttachUrl)) AS AttachUrlName, U.UnitName, (CASE WHEN Item.UpState='1' THEN '本单位' WHEN Item.UpState='2' THEN '待上报' when Item.UpState='3' then '已上报' when Item.UpState='4' then '上报失败' end) as UpStates, ConstUpState.ConstText AS UpStateName, AttachFile.AttachFileId, AttachFile.ToKeyId, AttachFile.AttachSource, AttachFile.AttachUrl FROM Supervise_SubUnitReportItem AS Item LEFT JOIN Base_Unit AS U ON U.UnitId=Item.UnitId LEFT JOIN AttachFile AS AttachFile ON Item.SubUnitReportItemId=AttachFile.ToKeyId LEFT JOIN Sys_Const AS ConstUpState ON Item.UpState=ConstUpState.ConstValue and ConstUpState.GroupId='UpState' GO