Hi,
we have metadata in a table with this information (Attachment).
The task is to generate the CREATE TABLE statements for all Tables - based on these metadata (SQL2016) Simple Create Table like the Example below, with Datatype, null and pk. -> Meta-Data in Attachment.
Thanks and best Regards
Nicole
-- Example for finished Script
CREATE TABLE table_1
(
column_1 datetime(2) NULL,
column_2 nvarchar(8) PRIMARY KEY,
column_3 decimal NULL.
column_4 nvarchar(255) NULL
);
-- MetaData Schema (csv in Attachment)
CREATE TABLE [dbo].[EntityTerms](
[entity] nvarchar NOT NULL,
[col] nvarchar NOT NULL,
[data_type] nvarchar NOT NULL,
[length] nvarchar NOT NULL,
[PRECISION] nvarchar NOT NULL,
[scale] nvarchar NOT NULL,
[Col_Is_Nullable] [bit] NOT NULL,
[Is_Business_Key] [bit] NOT NULL
) ON [PRIMARY]
GO
-- Meta-Data
entity;col;data_type;length;PRECISION;scale;Col_Is_Nullable;Is_Business_Key
table_1;column_1;datetime(2);NULL;NULL;NULL;true;false
table_1;column_2;nvarchar();8;NULL;NULL;false;true
table_1;column_3;decimal;NULL;12;2;true;false
table_1;column_4;nvarchar();255;NULL;NULL;true;false
table_2;column_1;nvarchar();6;NULL;NULL;false;true
table_2;column_2;decimal;NULL;2;0;true;false
table_2;column_3;nvarchar();8;NULL;NULL;true;false
table_2;column_4;nvarchar();6;NULL;NULL;false;true
table_2;column_5;decimal;NULL;4;0;true;false