Share via

Import schema csv file into sqlserver

Anil 40 Reputation points
2024-12-10T19:14:17.3833333+00:00

Hi,

i have scenario , where i will get schema files in csv, there were around 100s of files.

here is sample schema csv file

TableName,columnae,LENGTH,vartype

Customer,custnumber,8,NUM

Customer,custname,100,char

Customer,custtype,12,char

Customer,custordernumber,20,NUM

Based on this schema file, i have to create Customer table with columns --custnumber,custname,custtype,custordernumber-- with data types in the sql server table.

File doesn't have any data, it has only schema.

Can someone help me how to import this to sqlserver?

Thank you,

Anil

Azure Data Factory
Azure Data Factory

An Azure service for ingesting, preparing, and transforming data at scale.


2 answers

Sort by: Most helpful
  1. AnnuKumari-MSFT 34,571 Reputation points Microsoft Employee Moderator
    2024-12-17T06:38:58.31+00:00

    Hi @Anil ,

    Thankyou for using Microsoft Q&A platform and thanks for posting your query here.

    I understand that you want to create multiple SQL tables using the schema provided in csv file.

    I have shared the details of solution using python and azure functions in the other thread : https://learn.microsoft.com/en-us/answers/questions/2129000/creating-sql-database-table-from-csv-schema-file-u

    Alternatively, in case you want to achieve it using ADF only, then probably you can try using dynamic mapping json file . Here is the video on the implementation part: Dynamic Column mapping in Copy Activity in Azure Data Factory

    Kindly accept the answer by clicking on Accept answer button. Thankyou

    Was this answer helpful?

    0 comments No comments

  2. elsvieta 416 Reputation points
    2024-12-10T19:24:36.2466667+00:00

    Have you tried:

    CREATE TABLE [dbo].[CUSTOMER](

    [CUSTNUMBER] [numeric](8, 0) IDENTITY(1,1) NOT NULL,
    
    [CUSTNAME] [varchar](100) NOT NULL,
    
    [CUSTTYPE] [char](12) NULL,
    
    [CUSTORDERNUMBER] [numeric](20, 0) NULL,
    

    CONSTRAINT [PK_CUSTOMER_CUSTNUMBER] PRIMARY KEY CLUSTERED

    (

    [CUSTNUMBER] ASC
    

    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

    GO

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.