1. Why we need
Delete query & Shrink Database?
When the SQL stored No.
of record in huge amount. There will be chance of Database crash &
data lost.
If the No. of record
is log in every 1 min then the size of row will be increase in Table.
If size of row
increase respectively size of SQL DB increase & size of C drive will
decrease.
a. First Take backup
of all DB.
b. Take confirmation
from customer.
c. Select &
Check the Table into DB.
d. Run the query to
delete record.
DELETE
FROM
[DB_NAME].[dbo].[TABLE_NAME]
WHERE
ScanTime BETWEEN
'2019-02-06
00:00:01'
AND
'2019-02-06
23:59:59'
Note:
always use WHERE
clause in delete statement. If you forget to use WHERE
clause then your all record will be delete from DB.
2.
When
you complete Delete statement in DB. Now you have to shrink Database.
---> Select
Database --> Right click --> Task --> Shrink --> Database -->
Shrink window open --> Click Ok.