In SSMS I have used Tasks/Generate Scripts on one server to create a script to recreate the schema only for a given database.
I added to this script some inserts for data in just a few of the tables.
I am now running this script on localhost SQLEXPRESS and I am getting syntax errors for the commented out parts of the script segment shown at the bottom of this post.
I am logged into localhost SQLEXPRESS as sa.
Is there a way to generate the script for a given SQLServer version / type? Or a way for it to check and support either?
Additionally I get these errors:
Msg 15007, Level 16, State 1, Line 144
'XXXYYYProdAdmin' is not a valid login or you do not have permission.
Msg 15007, Level 16, State 1, Line 147
'XXXZZZAdmin' is not a valid login or you do not have permission.
Msg 15151, Level 16, State 1, Line 151
Cannot add the principal 'XXXYYYProdAdmin', because it does not exist or you do not have permission.
Msg 15151, Level 16, State 1, Line 153
Cannot add the principal 'XXXZZZAdmin', because it does not exist or you do not have permission.
for these commands:
CREATE USER [XXXYYYProdAdmin] WITH DEFAULT_SCHEMA=[db_owner]
GO
/****** Object: User [XXXZZZAdmin] Script Date: 23/02/2022 10:45:32 ******/
CREATE USER [XXXZZZAdmin] WITH DEFAULT_SCHEMA=[dbo]
GO
ALTER ROLE [db_owner] ADD MEMBER [XXXService]
GO
ALTER ROLE [db_owner] ADD MEMBER [XXXYYYProdAdmin]
GO
ALTER ROLE [db_owner] ADD MEMBER [XXXZZZAdmin]
GO
Given that I am logged in as sa I would have thought I should be able to create these
Is there something in the script generation settings that I should have set to make this part succeed?
Many thanks,
Andrew
Other errors mentioned above:
--ALTER DATABASE SCOPED CONFIGURATION SET ACCELERATED_PLAN_FORCING = ON;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET ASYNC_STATS_UPDATE_WAIT_AT_LOW_PRIORITY = OFF;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET BATCH_MODE_ADAPTIVE_JOINS = ON;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET BATCH_MODE_MEMORY_GRANT_FEEDBACK = ON;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET BATCH_MODE_ON_ROWSTORE = ON;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET CE_FEEDBACK = ON;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET DEFERRED_COMPILATION_TV = ON;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET DW_COMPATIBILITY_LEVEL = 0;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET ELEVATE_ONLINE = OFF;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET ELEVATE_RESUMABLE = OFF;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET EXEC_QUERY_STATS_FOR_SCALAR_FUNCTIONS = ON;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET GLOBAL_TEMPORARY_TABLE_AUTO_DROP = ON;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET IDENTITY_CACHE = ON;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET INTERLEAVED_EXECUTION_TVF = ON;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET ISOLATE_SECURITY_POLICY_CARDINALITY = OFF;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET LAST_QUERY_PLAN_STATS = OFF;
--GO
ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMATION = OFF;
GO
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET LEGACY_CARDINALITY_ESTIMATION = PRIMARY;
GO
--ALTER DATABASE SCOPED CONFIGURATION SET LIGHTWEIGHT_QUERY_PROFILING = ON;
--GO
ALTER DATABASE SCOPED CONFIGURATION SET MAXDOP = 0;
GO
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET MAXDOP = PRIMARY;
GO
--ALTER DATABASE SCOPED CONFIGURATION SET OPTIMIZE_FOR_AD_HOC_WORKLOADS = OFF;
--GO
ALTER DATABASE SCOPED CONFIGURATION SET PARAMETER_SNIFFING = ON;
GO
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET PARAMETER_SNIFFING = PRIMARY;
GO
--ALTER DATABASE SCOPED CONFIGURATION SET PAUSED_RESUMABLE_INDEX_ABORT_DURATION_MINUTES = 1440;
--GO
ALTER DATABASE SCOPED CONFIGURATION SET QUERY_OPTIMIZER_HOTFIXES = OFF;
GO
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET QUERY_OPTIMIZER_HOTFIXES = PRIMARY;
GO
--ALTER DATABASE SCOPED CONFIGURATION SET ROW_MODE_MEMORY_GRANT_FEEDBACK = ON;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET TSQL_SCALAR_UDF_INLINING = ON;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET VERBOSE_TRUNCATION_WARNINGS = ON;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET XTP_PROCEDURE_EXECUTION_STATISTICS = OFF;
--GO
--ALTER DATABASE SCOPED CONFIGURATION SET XTP_QUERY_EXECUTION_STATISTICS = OFF;
--GO