How do I build a sql server

Bruno Manetta 0 Reputation points
2023-06-22T19:11:12.0433333+00:00

what services do I need that I can create stored procedures on a sql server to import CSV files locally in a folder and access it from Microsoft Sql Studio?

Azure SQL Database
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Alberto Morillo 34,671 Reputation points MVP Volunteer Moderator
    2023-06-22T20:46:38.9833333+00:00

    You just need to install SQL Server with the database engine service On the Feature Selection page of SQL Server setup program you just need to select "Database Engine Services".

    Once you have installed SQL Server and you get connected to the SQL Server isntance using SSMS, you can use BULK INSERT as shown below:

    BULK INSERT SchoolsTemp
        FROM 'C:\CSVData\Schools.csv'
        WITH
        (
        FIRSTROW = 2,
        FIELDTERMINATOR = ',',  --CSV field delimiter
        ROWTERMINATOR = '\n',   --Use to shift the control to next row
        ERRORFILE = 'C:\CSVDATA\SchoolsErrorRows.csv',
        TABLOCK
        )
    
    
    

    You can use SSMS Import/Export Wizard.

    Or you can use OPENROWSET.

    select id, start_date
    into sessions
    from OPENROWSET(BULK 'C:\TempDocs\Sessions.csv',
                    formatfile='C:\TempDocs\Sessions.fmt',
                    firstrow=2) as sessions_insert;
    
    
    

    Here you will find Microsoft documentation with more examples on how to use BULK INSERT or OPENROWSET.

    0 comments No comments

Your answer

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