Category Archives: Microsoft

Fix: How to remove hidden or phantom interfaces from Windows

Sometime you will note that some network interfaces would either not work or just give errors. This usually occurs when using images on HyperV but just in case you need to remove hidden or phantom devices like ‘network adapter #5’, here’s how.

:: Open command prompt
:: Type CMD
:: Type set devmgr_show_nonpresent_devices=1
:: From the same window (Do not close the window in this process), type devmgmt.msc

This will load the Device Manager. Now, click on ‘View’ and select ‘Show hidden devices’.

Now you can simply either delete the hidden/phantom interfaces or uninstall the device.

(946)

How To: Automated shrink transaction logs in SQL

Making a scheduled automated shrink logs for the databases with specific space to shrink.

DECLARE @Step1 VARCHAR(200)
DECLARE @Name varchar(50)

DECLARE DBNames CURSOR
FOR
SELECT NAME FROM sysdatabases WHERE dbid > 4
OPEN DBNames

FETCH NEXT FROM DBNames INTO @Name WHILE (@@FETCH_STATUS <> -1)

BEGIN

SET @Step1 = 'USE ' + @Name + '' + CHAR(10)
SET @Step1 = @Step1 + 'ALTER DATABASE [' + @Name + '] SET RECOVERY SIMPLE;' + CHAR(10)
SET @Step1 = @Step1 + 'DBCC SHRINKFILE (' +@Name + '_LOG, 500);' + CHAR(10)
SET @Step1 = @Step1 + 'ALTER DATABASE [' + @Name + '] SET RECOVERY FULL;' + CHAR(10)

EXEC (@Step1)

FETCH NEXT FROM DBNames INTO @Name
END

CLOSE DBNames
DEALLOCATE DBNames

(54849)