Once again ran into this issue; making a blog entry to retain the fix. I’m using Visual Studio 2015 with SQL Server Data Tools 2015. When creating a Foreach Loop with an ADO.net Enumerator the configuration area is blank.


There is no need to uninstall, reinstall, etc etc….  It is “TargetServerVersion” setting in the VS project configurations.  Not sure where to set it in the general VS configuration.

The reference I found with the fix is here.


I’m providing more details on the getting to the configuration change, since many DBA’s aren’t as Visual Studio savvy as developers are.

From the Project menu choose your SSISName Properties located at the bottom of the list.


Find “Configuration Properties” and set “Deployment Target Version” “TargetServerVersion”.



There is a warning that did not apply to my project.


Of course I had to find out what “SQL Server vNext” means to me in SSIS.  That’s another blog entry but started with exploring SQL Server 2017 and finding how SQL on Linux will be useful.


There are tables in a parent database where the data needs to be synced to child databases.  Using a simple EXCEPT statement efficiently identifies what rows are different.  Works great if the table schema is the same, otherwise the asterisk must be replaced with column names.

(SELECT * FROM Parent.SchemaName.TableName
SELECT * FROM Child.SchemaName.TableName AS A

Using column names is not a problem if the columns are known.  The issue I have, is the tables can change, and do, at any time.  The daily auditing stored procedure fails because of this.  If differences are not discovered with the audit, then no data is synced.

Step 1: Create temp tables

IF OBJECT_ID(‘tempdb..#ChildTableColumns’) IS NOT NULL
DROP TABLE #ChildTableColumns
CREATE TABLE #ChildTableColumns
( TableName VARCHAR(128)
, ColumnName VARCHAR(128))

IF OBJECT_ID(‘tempdb..#ParentTableColumns’) IS NOT NULL
DROP TABLE #ParentTableColumns
CREATE TABLE #ParentTableColumns
( TableName VARCHAR(128)
, ColumnName VARCHAR(128))

Step 2: Get Column Names for each child and parent table from system tables

INSERT INTO #ChildTableColumns
, ColumnName)
SELECT T.name AS TableName
, C.name AS ColumnName
FROM ChildDatabase.sys.tables AS T
INNER JOIN ChildDatabase.sys.columns AS C
ON C.object_id = T.object_id
WHERE T.name IN (‘Table1′,’Table2’)

INSERT INTO #ParentTableColumns
, ColumnName)
SELECT T.name AS TableName
, C.name AS ColumnName
FROM ParentDatabase.sys.tables AS T
INNER JOIN ParentDatabase.sys.columns AS C
ON C.object_id = T.object_id
WHERE T.name IN (‘Table1′,’Table2’)

Step 3: Get Comma Delimited list of columns that are the same

, STUFF((SELECT (‘, ‘ + CT.ColumnName + ”)
FROM #ClientTableColumns AS CT
WHERE CT.TableName = C.TableName
ORDER BY CT.ColumnName
FOR XML PATH(”)) , 1, 2 , ”) AS ColumnsList
, CA.ColumnName
FROM #ChildTableColumns AS CA
INNER JOIN #ParentTableColumns AS CO
ON CO.TableName = CA.TableName AND CO.ColumnName = CA.ColumnName) AS C

Use the comma delimited list in a variable for a dynamic sql statement to replace the asterisk in the above EXCEPT statement.  For my use case the process must iterate over many Parent databases and hundreds of Child databases.





Created a new SQL Agent job calling an SSIS package in the local SSIS Catalog.

Error Message:  Login failed. The login is from an untrusted domain and cannot be used with Windows authentication

Error: 18452, Severity: 14, State: 1.

I struggled with this error knowing that I was working in the same domain and using the same AD account for the Agent and SSIS services.  The connection string in the package was set correctly and worked fine in my individual development environment.

The fix; the server reference in the connection manager was an alias that apparently didn’t have SPN’s correctly created.  I think it was an old alias.  Changed the server reference in the connection manager to the server name as it appears in AD and it worked fine.



I have SQL Agent Operators named ‘Alerts’ and ‘MSXOperator’.  I use the ‘Alerts’ operator for SQL Server native generated fatal errors.   Didn’t realize the MSXOperator was created on Target SQL Server Agent by the process of enlisting as Target to the Master.  Changing the ‘Alerts’ Operator from my Central Management Server worked like a charm, but the MSXOperator didn’t work.  The error message is “Cannot modify or delete operator ‘MSXOperator’ while this server is a TSX.”.  Of course I googled the error, others had the error but there were no answers.

The error is generated on the target but not the master when this statement is run.

USE [msdb]
EXEC msdb.dbo.sp_update_operator @name=N’MSXOperator’,

Execute the statement on the master instance to change the email address.  In my case I was changing to a distribution group from my personal account.  Look at the Target from Manage Target Servers on the master instance.  The download instruction Operation of “6(RE_ENLIST)” is created and on the next polling will download the email address change to the target.


Check the properties of MSXOperator on the target server.  It’s been changed.  When you exit the properties you will still get the error message “Cannot modify or delete operator ‘MSXOperator’ while this server is a TSX.”.  That’s one of those SQL Server twitches.

Need to get the warranty type and expiration date for all Dell computers and servers in the enterprise and save it to a SQL Server staging table for down stream consumption into the Asset Data Warehouse.

The Powershell script works, but I want the iteration results of the API call to write to a hash table and then make one connection to the database for insert there.

#Initializer server, database, connection, query, and data adapter
$serverName = “Instance Name”
$databaseName = “Database Name”

$Query = “SELECT SerialNumber FROM ViewWithAListOfSerialNumbers’;”

$Connection = New-Object System.Data.SQLClient.SQLConnection
$Connection.ConnectionString =”Server=$serverName;Database=$databaseName;trusted_connection=true;”
$DataAdapter = New-Object System.Data.SqlClient.SqlDataAdapter($Query,$Connection)
$DataSet = New-Object System.Data.DataSet
$DataAdapter.Fill($DataSet) | Out-Null

# Create the function for the call to Dell
Function fnDellWarranty ($ServiceTag) {
$service = New-WebServiceProxy -Uri “http://xserv.dell.com/services/AssetService.asmx?WSDL”
$guid = [guid]::NewGuid()
$info = $service.GetAssetInformation($guid,’Dell Warranty’,$ServiceTag)

if($info -ne $Null){

‘StartDate’ = $($($info[0].Entitlements.StartDate.ToShortDateString()) | Sort-Object)[0]

$obj = New-Object -TypeName psobject -Property $result


Return $obj

#add dataset to array
$SArray = $DataSet.tables[0].Rows

# Clear the Sql that will stage the data
IF ($SArray.count -gt 0) {
$cmd = New-Object System.Data.SqlClient.SqlCommand

$cmd.Connection = $Connection
$cmd.CommandText = “TRUNCATE TABLE stage.DellWarranty;”


$SArray | ForEach-Object {

#Run function
If(!($_.SerialNumber -eq $Null)) {

$fnR = $(fnDellWarranty $_.SerialNumber)

#set variables
$StartDate = $fnR.StartDate
$ShipDate = $fnR.ShipDate
$DaysLeft = $fnR.DaysLeft
$ServiceLevelDescription = $fnR.ServiceLevelDescription
$EndDate = $fnR.EndDate
$SystemType = $fnR.SystemType
$SystemModel = $fnR.SystemModel
$EntitlementType = $fnR.EntitlementType
$ServiceProvider = $fnR.ServiceProvider
$ServiceTag = $fnR.ServiceTag
#my mistake was in the loop. I had Return $SerialNumber, $StartDate, then nothing would write to the table. Once that was returned, this worked

if($fnR -ne $Null){
$cmd = New-Object System.Data.SqlClient.SqlCommand

$cmd.Connection = $Connection
$cmd.CommandText = “SET NOCOUNT ON; INSERT INTO dbo.DellWarranty(SerialNumber,ServiceTag,StartDate,ShipDate,DaysLeft,ServiceLevelDescription,EndDate,SystemType,SystemModel,EntitlementType,ServiceProvider)`
-f $_.SerialNumber, $ServiceTag,$StartDate,$ShipDate,$DaysLeft,$ServiceLevelDescription,$EndDate,$SystemType,$SystemModel,$EntitlementType,$ServiceProvide



$SerialNumber =$Null

Many comments praise the use of adding a linked server to AD and creating a view to capture user information.  There is a 1000 record limit, so that presents an obstacle to work around.  I struggled with permissions and never got a linked server to AD to work.  I’m not a Domain Admin and have limited exposure to AD in general.  Links to those methods are below.

Using Power shellflat filesSSIS package and Agent Job I created system to capture AD information on an hourly basis.  I experimented with the Power Shell Active Directory module a lot.  Having never had access to AD, it was a whole new world learning the structure and query syntax.  I made scripts for user group membership, computers  and here is the script to capture user information.

Import-module ActiveDirectory


# User details list

$cr = “`r” #Carriage Return
$tq = “`”” #Text Qualifier
#Column Headings

Out-File -Width 2147483647 -Encoding ASCII -FilePath \\PathName\Process\Spool\AdUser.txt
#Data Rows
Get-ADUser -Filter * -Properties * |
ForEach-object {
$AccountExpirationDate = $_.AccountExpirationDate
$AccountExpires = $_.AccountExpires
$assistant = $_.assistant
$Deleted = $_.Deleted
$Department = $_.Department
$DistinguishedName = $_.DistinguishedName
$EmailAddress = $_.EmailAddress
$EmployeeNumber = $_.EmployeeNumber
$Enabled = $_.Enabled
$extensionAttribute4 = $_.extensionAttribute4
$extensionAttribute5 = $_.extensionAttribute5
$extensionAttribute6 = $_.extensionAttribute6
$extensionAttribute7 = $_.extensionAttribute7
$extensionAttribute9 = $_.extensionAttribute9
$extensionAttribute11 = $_.extensionAttribute11
$extensionAttribute12 = $_.extensionAttribute12
$extensionAttribute13 = $_.extensionAttribute13
$extensionAttribute15 = $_.extensionAttribute15
$GivenName = $_.GivenName
$HomePhone = $_.HomePhone
$Initials = $_.Initials
$LastLogonDate = $_.LastLogonDate
$Manager = $_.Manager
$MobilePhone = $_.MobilePhone
$Modified = $_.Modified
$Name = $_.Name
$Office = $_.Office
$OfficePhone = $_.OfficePhone
$SamAccountName = $_.SamAccountName
$Surname = $_.Surname
$Title = $_.Title
} |
Out-File -Width 2147483647 -Encoding ASCII -FilePath \\PathName\Process\Spool\AdUser.txt -append # output

The output does need to be a UNC path. Once the flat files are created then SSIS and T-sql can take it from there to update the database of users and computers.  The project is an inventory of users, computers and the software installed on their computers.  The firm users have some expensive software and the licensing must be closely tracked.

Here are the links to other discussion on pulling in AD to SQL Server.



There are many scripts in blogs and forums to remove a user from all databases in a SQL Server instance.  I want to keep as simple as possible and just drop the database user account.  This script will error on the databases where the users owns a schema.  I want to know those databases and want to retain the login.  Plus having heard so many warnings about cursors I don’t use them.  Some would say a loop in a WHILE statement is the same thing as a cursor.

Simply put, get a list of databases to check for the user, loop through each, and drop the user if it exists.

DECLARE @Databasename VARCHAR(128)
, @Command VARCHAR(255)
, @UserName VARCHAR(128)

SELECT @UserName = ” — Enter a User

(DatabaseName VARCHAR(128))

( DatabaseName )
FROM master.sys.databases
WHERE name <> ‘master’

SELECT TOP 1 @Databasename = Databasename

SELECT @Command = ‘USE [‘ + @Databasename + ‘] IF EXISTS (SELECT * FROM ‘ + @Databasename + ‘.sys.database_principals WHERE name = N’
+ ”” + @UserName + ”” + ‘) DROP USER [‘+ @UserName +’]’

PRINT @Command
EXECUTE (@Command )

DELETE FROM @DBList WHERE DAtabaseName = @Databasename