'How to make SqlPackage exclude indexes?
We're using SqlPackage to generate scripts via the Script action. Does anyone know a way to get it to exclude indexes? Can't seem to find a way.
The SqlPackage reference gives several /p: properties to do with excluding a whole raft of other object types, which we are using to good effect, but not indexes. Indexes we can only tweak, not exclude, it seems. We're using SQL 2017 but the same goes for SQL 2019.
Has anyone found a way to completely exclude indexes from the script, so that they are just left as they are on the target db, the same as can be done for all the other types of SQL object?
/p: ExcludeObjectTypes=(STRING) A semicolon-delimited list of object types that should be ignored during deployment.
Valid object type names are Aggregates, ApplicationRoles, Assemblies, AsymmetricKeys, BrokerPriorities, Certificates, ColumnEncryptionKeys, ColumnMasterKeys, Contracts, DatabaseRoles, DatabaseTriggers, Defaults, ExtendedProperties, ExternalDataSources, ExternalFileFormats, ExternalTables, Filegroups, FileTables, FullTextCatalogs, FullTextStoplists, MessageTypes, PartitionFunctions, PartitionSchemes, Permissions, Queues, RemoteServiceBindings, RoleMembership, Rules, ScalarValuedFunctions, SearchPropertyLists, SecurityPolicies, Sequences, Services, Signatures, StoredProcedures, SymmetricKeys, Synonyms, Tables, TableValuedFunctions, UserDefinedDataTypes, UserDefinedTableTypes, ClrUserDefinedTypes, Users, Views, XmlSchemaCollections, Audits, Credentials, CryptographicProviders, DatabaseAuditSpecifications, DatabaseScopedCredentials, Endpoints, ErrorMessages, EventNotifications, EventSessions, LinkedServerLogins, LinkedServers, Logins, Routes, ServerAuditSpecifications, ServerRoleMembership, ServerRoles, ServerTriggers.
Please note, we know about /p: DropIndexesNotInSource=True/False
and /p: IgnoreIndexOptions=True/False
but these are not sufficient.
Solution 1:[1]
I believe you need to use a publish.xml file. See this answer for the rough idea. The question it answers has a sample file. If you set up to not include indexes via the GUI then the file should contain something like <ExcludeIndexes>True</ExcludeIndexes>
.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | SMM |