Posts

Showing posts from 2012

Phone Manner

That's a good question. Let me find out for you. I am not sure. Let me find someone who knows. May I tell her who is calling? Do you want me to put you through to Mr.X? Could you please hold the line? I am afraid. She is not in at the moment. Can I give her a message? --------------- pop out: She is just popped out to the shop. (appear suddenly) Could you please get her to ring me back please? Sure, who should I say called?

Powershell code snipets

$DirArray=Get-ChildItem c:\temp | ?{ $_.PSIsContainer } | Select-Object FullName $arrFolderName = @() $arrFolderSize = @() $Combine = @() $varCount = 0   #### Allocate Memory for all arrays for ($i = 0;$i -lt $DirArray.length;$i++){ $arrFolderName += @($i) $arrFolderSize += @($i) $Combine += @($i) }   #### Populate folder name and size in two arrays Foreach($Item in $DirArray) { $Item = "$Item" $pos = $Item.IndexOf("=") $SubActualDir=$Item.Substring($pos+1) $pos=$SubActualDir.IndexOf("}") $actualDir=$SubActualDir.Substring(0,$pos) $arrFolderName[$varCount] = $actualDir $arrFolderSize[$varCount] = (gci $actualDir -r -force -exclude *.pst | measure -sum -property Length).Sum #"$arrFolderName[$varCount] :  $arrFolderSize[$varCount]" $varCount = $varCount + 1 }   #### Print in single line for ($i = 0;$i -lt $varCount;$i++){ ##echo $arrFolderName[$i] $arrFolderSize[$i] ##"$arrFolderNa

PowerShell: Simple task for finding top sized folders

First save the PS script Get-DirStats.ps1 Source Code of Get-DirStats.ps1 # Get-DirStats.ps1 # Written by Bill Stewart # Outputs file system directory statistics. #requires -version 2 <# .SYNOPSIS Outputs file system directory statistics. .DESCRIPTION Outputs file system directory statistics (number of files and the sum of all file sizes) for one or more directories. .PARAMETER Path Specifies a path to one or more file system directories. Wildcards are not permitted. The default path is the current directory (.). .PARAMETER LiteralPath Specifies a path to one or more file system directories. Unlike Path, the value of LiteralPath is used exactly as it is typed. .PARAMETER Only Outputs statistics for a directory but not any of its subdirectories. .PARAMETER Every Outputs statistics for every directory in the specified path instead of only the first level of directories. .PARAMETER FormatNumbers Formats numbers in the output object to include thousands separators. .PARAME

To Work With

Registration SYSTEM DSN via command prompt "C:\WINDOWS\regedit.exe" /s " \\Dfcgsts22\d$\temp\DFCGSTS_CBMSProd.reg " "C:\WINDOWS\system32\odbcad32.exe" configsysdsn "SQL Server" "DSN=CBMSProd" http://www.itechtalk.com/thread3075.html http://rssexplorer.codeplex.com/ --------- SELECT DB_NAME ( database_id ) AS DatabaseName , name AS LogicalFileName , physical_name AS PhysicalFileName FROM sys . master_files AS mf ------------ use master; select name, suser_sname(owner_sid) from sys.databases; --- USE msdb; SELECT  A.Name AS JobName,  B.name AS JobOwner  FROM dbo.sysjobs A  inner join master.sys.syslogins B on  A.owner_sid = B.sid where a.enabled = 1; Oracle 9i imported database shows error ORA 600 on dropping user http://www.dbasupport.com/forums/showthread.php?52489-Error-while-drop-user DECLARE @name VARCHAR(50) DECLARE db_cursor CURSOR FOR  SELECT name FROM master.dbo.sysdatabases WHERE name NOT IN

SQL Server: Add logins from command prompt

To start SQLSERVER instance in a single user mode and shortens the startup time SQLSERVR -m–c   To add a Windows user to the sysadmin fixed server role in SQL Server 2005 as a failure recovery mechanism SQLCMD -s computername -E Exec sp_addsrvrolemember @loginname=’computername\local account’ GO Finally reboot the machine. Ref: - http://msdn.microsoft.com/en-us/library/ms180965(v=sql.105).aspx - http://support.microsoft.com/kb/937682 - Paul Copley, Sr. DBA

Oracle 9i: Temp Tablespace Usage Monitoring

-- Create the monitoring Table create table ztbl_temp_monitor (snap_time date default sysdate, Total_Size_MB int, Used_Size_MB int, Free_Size_MB int, Tablespace_name varchar(30) ); -- Insert command for data insert into ztbl_temp_monitor(Tablespace_name, Total_Size_MB, Used_Size_MB, Free_Size_MB) select b.tablespace_name, b.SizeMB, nvl(a.UsageMB, 0) as UsageMB, b.SizeMB - nvl(a.UsageMB, 0) as FreeMB from (select sum(BLOCKS) * b.VALUE / 1024 / 1024 as UsageMB, tablespace as tablespace_name from v$tempseg_usage a, v$parameter b where b.name = 'db_block_size' group by TABLESPACE, b.VALUE) a, (select sum(bytes) / 1024 / 1024 as SizeMB, tablespace_name from dba_temp_files group by tablespace_name) b where a.tablespace_name(+) = b.tablespace_name; -- Create a procedure to incorporate the insert command CREATE OR REPLACE PROCEDURE zproc_temp_usage_monitor IS BEGIN insert into ztbl_temp_monitor(Tablespace_name, Total_Size_MB, Used_Size_MB, Free_Size_MB) select b.tablespace_name

SQL Server: Scripting to backup and restore at one go

Take All Backups to a single location DECLARE @name VARCHAR ( 50 ) -- database name   DECLARE @path VARCHAR ( 256 ) -- path for backup files   DECLARE @fileName VARCHAR ( 256 ) -- filename for backup   DECLARE @fileDate VARCHAR ( 20 ) -- used for file name   SET @path = '\\servername\SQLBackups\foldername\'     SELECT @fileDate = CONVERT ( VARCHAR ( 20 ), GETDATE (), 112 )   DECLARE db_cursor CURSOR FOR   SELECT name FROM master . dbo . sysdatabases WHERE name NOT IN ( 'master' , 'model' , 'msdb' , 'tempdb' , 'ReportServer' , 'ReportServerTempDB' , 'anyOtherDB' )     OPEN db_cursor    FETCH NEXT FROM db_cursor INTO @name      WHILE @@FETCH_STATUS = 0    BEGIN           --SET @fileName = @path + @name + '_' + @fileDate + '.BAK'          SET @fileName = @path + @name + '.BAK'          Print 'BACKUP DATABASE ' + @name