# Export và Import table big data dùng CMD

## 1. Export table SQL ra file .txt dùng lệnh BCP

```
BCP "Select * From SIVIPTT133_APP..zcdmvv" queryout C:\Sivip\zcdmvv_bcp.txt -c -w -Smaychu -Usa -P123456
```

**Các thông số:**&#x20;

\+ queryout: là xuất file ra

\+ w là tham số để xuất dữ liệu Unicoe

\+ S là tên máy chủ SQL

\+ U: User SQL

\+ P: là Pass của SQL

## 2. Import file txt ở trên vào data SQL

**Cách 1: Dùng MSSM của SQL**

```
BULK INSERT SIVIPTT133_APP..zcdmvv FROM 'C:\Sivip\zcdmvv_bcp.txt'
```

**Cách 2: Dùng lệnh DOS BCP**

```
bcp SIVIPTT133..zcdmvv in C:\Sivip\zcdmvv_bcp.txt -Smaychu -Usa -P123456 -c -w
```

> **Đánh giá:**
>
> * Export và Import cực kỳ nhanh, thực hiện vài triệu bảng ghi chỉ trong vài vài phút
> * Chỉ xuất ra file định dạng txt, csv hoặc Excel chứ không có định dạng .sql
> * Nhược điểm, lúc Import dữ liệu chưa chính xác lắm, hay bị thiếu dòng, cần tìm hiểu sâu để hoàn thiện
> * Nếu thực hiện Import Cách 1 sẽ có báo lỗi chính xác tại dòng nào
> * Thực hiện Import Cách 2 sẽ, báo lỗi rất chung chung


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kythuat.sivip.vn/master.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
