Kiểm tra Table

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

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

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

Last updated