Created
September 18, 2018 19:19
-
-
Save thanley11/ad62c1937ffdd12026f1e9b4e4ca1b53 to your computer and use it in GitHub Desktop.
Audit Table with parent and children
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE DW | |
/* Drop table dbo.dim_audit */ | |
IF EXISTS ( SELECT * | |
FROM dbo.sysobjects | |
WHERE id = OBJECT_ID(N'[dbo].[dim_audit]') | |
AND OBJECTPROPERTY(id, N'IsUserTable') = 1 ) | |
DROP TABLE dbo.[dim_audit] | |
GO | |
CREATE TABLE [dbo].[dim_audit]( | |
[audit_key] [int] IDENTITY(1,1) NOT NULL, | |
[ParentAuditKey] [int] NOT NULL, | |
[TableName] [varchar](50) NOT NULL, | |
[PkgName] [varchar](100) NOT NULL, | |
[PkgGUID] [uniqueidentifier] NULL, | |
[PkgVersionGUID] [uniqueidentifier] NULL, | |
[PkgVersionMajor] [smallint] NULL, | |
[PkgVersionMinor] [smallint] NULL, | |
[ExecStartDT] [datetime] NOT NULL, | |
[ExecStopDT] [datetime] NULL, | |
[ExecutionInstanceGUID] [uniqueidentifier] NULL, | |
[ExtractRowCnt] [bigint] NULL, | |
[InsertRowCnt] [bigint] NULL, | |
[UpdateRowCnt] [bigint] NULL, | |
[ErrorRowCnt] [bigint] NULL, | |
[InferredMemberRowCnt] [bigint] NULL, | |
[TableInitialRowCnt] [bigint] NULL, | |
[TableFinalRowCnt] [bigint] NULL, | |
[TableMaxDateTime] [datetime] NULL, | |
[SuccessfulProcessingInd] [char](1) NOT NULL, | |
CONSTRAINT [PK_dbo.dim_audit] PRIMARY KEY CLUSTERED | |
( | |
[audit_key] ASC | |
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | |
) ON [PRIMARY] | |
SET IDENTITY_INSERT [dbo].[dim_audit] ON | |
INSERT [dbo].[dim_audit] ([audit_key], [ParentAuditKey], [TableName], [PkgName], [PkgGUID], [PkgVersionGUID], [PkgVersionMajor], [PkgVersionMinor], [ExecStartDT], [ExecStopDT], [ExecutionInstanceGUID], [ExtractRowCnt], [InsertRowCnt], [UpdateRowCnt], [ErrorRowCnt],[InferredMemberRowCnt], [TableInitialRowCnt], [TableFinalRowCnt], [TableMaxDateTime], [SuccessfulProcessingInd]) VALUES (-1, -1, N'Not Applicable', N'Initial Load', NULL, NULL, 0, 0, getdate(), getdate(), NULL, 0, 0, 0, 0, 0, 0, 0, getdate(), N' ') | |
SET IDENTITY_INSERT [dbo].[dim_audit] OFF | |
ALTER TABLE [dbo].[dim_audit] ADD DEFAULT ('Unknown') FOR [TableName] | |
GO | |
ALTER TABLE [dbo].[dim_audit] ADD DEFAULT ('Unknown') FOR [PkgName] | |
GO | |
ALTER TABLE [dbo].[dim_audit] ADD DEFAULT (getdate()) FOR [ExecStartDT] | |
GO | |
ALTER TABLE [dbo].[dim_audit] ADD DEFAULT ('N') FOR [SuccessfulProcessingInd] | |
GO | |
ALTER TABLE [dbo].[dim_audit] WITH CHECK ADD CONSTRAINT [FK_dbo_dim_audit_ParentAuditKey] FOREIGN KEY([ParentAuditKey]) | |
REFERENCES [dbo].[dim_audit] ([audit_key]) | |
GO | |
ALTER TABLE [dbo].[dim_audit] CHECK CONSTRAINT [FK_dbo_dim_audit_ParentAuditKey] | |
GO | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
def div2(x):
b=(x%2)
if b==0 is True:
print(x/2)
else:
print("not divisible by 2")
def div2mk2(x):
b=x%2
if b==0 is True:
print(x/2)
if b==0 is False:
print("not divisible by 2")
def div2mk3(x):
b=x%2
if b>-1 is True:
print(x/2)
if b>-1 is False:
print("not divisible by 2")
def div2mk4(x):
if b(x)==0 is True:
print(x/2)
else:
print("not divisible by 2")
WORKS
def div2mk5(x):
if (x%2)==0:
print(x/2)
else:
print("not divisible by 2")