> 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/effect/kiem-tra-table.md).

# Kiểm tra Table

## Kiểm tra table trên SQL, vào quản lý Form, gọi mở form00099

```sql
SELECT 
    s.name AS [Schema],
    t.name AS [Table Name],
    t.create_date AS [Created Date],
    t.modify_date AS [Last Modified]
FROM sys.tables t
INNER JOIN sys.schemas s ON t.schema_id = s.schema_id
where t.name like '%__REP%' --Table bắt đầu chữ _Rep
ORDER BY t.create_date DESC, [Table Name];
```

## XÓA ĐI TABLE TEMP

```sql
declare @sql nvarchar(max),@tbl nvarchar(500)
declare cs cursor for
select TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME like '__Rep_%'
open cs
fetch next from cs into @tbl
While @@FETCH_STATUS=0
begin
	set @sql='drop table '+@tbl
	exec sp_executesql @sql
	set @sql=''
fetch next from cs into @tbl
end 
close cs
deallocate cs
```

## XÓA ĐI VIEW TEMP

<pre class="language-sql"><code class="lang-sql"><strong>declare @sql nvarchar(max),@tbl nvarchar(500)
</strong>declare cs cursor for
select TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME like 'ZzzViewTempRerpot%'
open cs
fetch next from cs into @tbl
While @@FETCH_STATUS=0
begin
	set @sql='drop view '+@tbl
	exec sp_executesql @sql
	set @sql=''
fetch next from cs into @tbl
end 
close cs
deallocate cs
</code></pre>
