> For the complete documentation index, see [llms.txt](https://kythuat.dtechvn.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kythuat.dtechvn.com/sql-server/mot-so-loi-truy-van-sql.md).

# 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.
