Wednesday 15 February 2023

How to insert BULK data using SQL Server ?

 HOW TO INSERT BULK DATA INTO TABLE 

How to insert bulk data into table sql

SQL SERVER BULK INSERT

in this Article, you’ll learn how to use the SQL Server BULK INSERT statement to import a data file into a database table.

Using BULK INSERT statement you can insert data into table or views.

Basic syntax for bulk inserts.

BULK INSERT tablename

FROM path_to_file

WITH options;

 

Before loading data into table or views you should have must csv file with data.

BULK INSERT Employees

FROM 'D:\data\employees.csv'

WITH (

  FIELDTERMINATOR = ',',

  ROWTERMINATOR = '\n',

  FIRSTROW = 2

);

In this statement:

The table name is Employees. If you connect to the master database, you need to specify the full table name like HR.dbo.Employees

The path to the data file is D:\data\employees.csv.

The WITH clause has three options: The comma (,) as the FIELDTERMINATOR, which is a separator between columns. The newline ('\n') as the ROWTERMINATOR, which separate between rows. 

Finally, query the data from the Employees table:

SELECT * FROM employees;

 What is cursor in sql server ?

what is stored procedure in sql server?

what is CTE in sql server ?

SQL interview question and answer?

 

 


Latest
Next Post
Related Posts

No comments:

Post a Comment