If the log file (LDF) of the database is found is too powerful, the following two steps can be taken:
(1) Change the Recovery Model to Simple (default is FULL)
(2) Run the DBCC SHRINKDATABASE command to compress the database
Function code:
Public Shared Function ShrinkDatabase (Byval dbconnection as sqlclient.sqlconnection, byval dbname as string) as boolean
'Set the recovery mode to Simple and the shrink the database
DIM SSQL AS String
SSQL = "ALTER DATABASE [" & DBNAME & "] Set Recovery SIMPLE"
DIM SQLCMD As New Sqlclient.sqlcommand (SSQL, DBConnection)
Sqlcmd.executenonQuery ()
SSQL = "DBCC ShrinkDatabase (N '" & DBNAME & "', TRUNCATEONLY"
Sqlcmd.commandtext = SSQL
Sqlcmd.executenonQuery ()
END FUNCTION