Note: Technical Talk being moved to:
www.nazimcricket.com/wiki


Monday, 28 June 2010

Truncate and Shrink Database

On SQLServer I've learnt that we can't take for granted that a table truncate will reuse storage. Therefore to reclaim empty space following the truncate of a large table, I ran:
DBCC SHRINKDATABASE (DBNAME, TRUNCATEONLY)
GO

Friday, 18 June 2010

Unix Yesterday's Date

date -d '1 day ago'

date -d 'yesterday'

Tuesday, 8 June 2010

TSM - Command Line Restore

dsmc restore "/path/file*" -pick -inactive -subdir=y

to pick files - enter line number followed by +, separated by colons for example 1:2+

Once selected O for ok will restore them.

Tuesday, 1 June 2010

cmdline stop/start/check-status of a service remotely

Using the sc utility ...
sc \\servername stop ServiceName
sc \\servername start ServiceName

sc \\servername query ServiceName

Inspired by this, I decided to create a little DOS program which an end-user could use to stop/start a service.
@ECHO OFF
SETLOCAL enableextensions

for /f "tokens=4" %%s in ('sc query OracleServiceXE ^| find /i "state"') do (SET _state=%%s)

for /f "tokens=2" %%t in ('sc query OracleServiceXE ^| find /i "service_name"') do (SET _service_name=%%t)

ECHO ================================
ECHO %_service_name% is %_state%
ECHO ================================


if %_state%==RUNNING goto SRVC-R
if %_state%==STOPPED goto SRVC-S

:SRVC-R
echo %_service_name% Is RUNNING, would you like to STOP it? Y/N
set /p Input1=
if /i "%Input1%"=="y" sc stop OracleServiceXE
echo.
sleep 10

for /f "tokens=4" %%s in ('sc query OracleServiceXE ^| find /i "state"') do (echo %_service_name% is %%s)

pause
exit /b


:SRVC-S
echo %_service_name% Is STOPPED, would you like to START it? Y/N
set /p Input1=
if /i "%Input1%"=="y" sc start OracleServiceXE
echo.
sleep 10

for /f "tokens=4" %%s in ('sc query OracleServiceXE ^| find /i "state"') do (echo %_service_name% is %%s)

pause
exit /b