I am using the following script:
DECLARE @dbName NVARCHAR(20) = \'ABC\';
EXEC ( N\' USE \' + @dbName + \'
GO
-- Create Schema
CREATE SCHEMA meta
GO
-- Create L
You can use following script for solution to your requirement with the help of unsupported undocumented stored procedure sp_MSForEachDB
EXEC sp_MSForEachDB '
Use [?];
IF ''[?]'' = ''[ABC]''
begin
-- Create Schema
exec sp_executesql N''CREATE SCHEMA meta''
end
'
EXEC sp_MSForEachDB '
Use [?];
IF ''[?]'' = ''[ABC]''
begin
-- Create Log Table
CREATE TABLE meta.LogAudit(
[EventDate] [datetime] NOT NULL DEFAULT (getdate()),
[EventType] [nvarchar](64) NULL,
)
end'