# Một số lỗi truy vấn SQL

## Could not continue scan with NOLOCK due to data movement

**Mô tả:**

* Lỗi này khi có thẻ không select truy vấn được dữ liệu
* Xem báo cáo , tạo lại view nhưng không ra được kết quả

**Cách khắc phục:**

```sql
-- Chạy câu lệnh sau để sửa lỗi:
-- Nhớ sửa DBNAME = tên của data sql đang lỗi
USE master;
ALTER DATABASE DBNAME SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
DBCC CHECKDB ('DBNAME', REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS;
GO
ALTER DATABASE DBNAME SET MULTI_USER;
GO
```

## is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.

**Mô tả:**

* Lỗi này khi attach database không được do phân vùng ổ cứng đang để  chế độ nén file&#x20;

**Cách khắc phục:**

<figure><img src="/files/8tqGJEorL5yQd5Jq154G" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/TSqcRPFxuEf9fMp57TmB" alt=""><figcaption></figcaption></figure>

* Sau khi bỏ tích Compress contents to save disk space xong thì nhấn OK rồi OK tiếp để windows bắt đầu bỏ nén các file trong thư mục đó là được
* Khi chạy xong thì có thể attach lại được file .mdf của SQL được tiếp.


---

# 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.dtechvn.com/sql-server/mot-so-loi-truy-van-sql.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.
