$dMonth= (Get-Date).AddMonths(-0).ToString("dd-MM-yyyy")
$DBServer = "cdiserv1"
$databasename = "SUBSCRIBER"
$Connection = new-object system.data.sqlclient.sqlconnection
$Connection.ConnectionString ="server=$DBServer;database=$databasename;trusted_connection=True"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlQuery = @"
SELECT isnull(B.AcctLineCode, '') AS OLC,
isnull(B.AcctNum, '') AS OAN,
isnull(A.AcctLineCode, '') as NLC,
isnull(A.AcctNum, '') AS NAN,
isnull(B.Name, '') AS ONA,
isnull(A.Name, '') as NNA,
isnull(B.UserField1, '') AS O1,
isnull(B.UserField2, '') AS O2,
isnull(B.UserField3, '') AS O3,
isnull(A.UserField1, '') AS N1,
isnull(A.UserField2, '') AS N2,
isnull(A.UserField3, '') AS N3,
case when A.AcctNum != B.AcctNum or A.AcctLineCode != B.AcctLineCode then 'ACCOUNT MOVED'
when A.Name != B.Name then 'NAME CHANGE'
when A.UserField1 != B.UserField1 OR A.UserField2 != B.UserField2 OR A.UserField3 != B.UserField3 then 'FEATURE CHANGE'
when A.AccountID is not null and B.AccountID is null then 'ADDED ACCOUNT'
when A.AccountID is null and B.AccountID is not null then 'DEELETED ACCOUNT' end [Result]
FROM [CDISERV1].[SUBSCRIBER].[dbo].[Subscriber Data] A
FULL OUTER JOIN [CDISERV2].[SUBSCRIBER].[dbo].[Subscriber Data] B ON A.AccountID = B.AccountID
WHERE (A.AccountID is not null and B.AccountID is null)
OR (A.AccountID is null and B.AccountID is not null)
OR A.AcctLineCode != B.AcctLineCode
OR A.AcctNum != B.AcctNum
OR A.Name != B.Name
OR A.UserField1 != B.UserField1
OR A.UserField2 != B.UserField2
OR A.UserField3 != B.UserField3
"@
$Connection.open()
$SqlCmd.CommandText = $SqlQuery
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$SqlCmd.Connection = $Connection
$dt = New-Object System.Data.DataTable
$SqlAdapter.Fill($dt) | Out-Null
$Connection.Close()
$dt | Export-Csv -Path Z:\OP\CSV\AIS$dMonth.CSV -force -NoTypeInformation
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.