Posts Tagged: Script

SQL Server TSQL – Take a database offline and online

— Create Test DB CREATE DATABASE [DBName] GO — Take the Database Offline ALTER DATABASE [DBName] SET OFFLINE WITH ROLLBACK IMMEDIATE GO — Take the Database Online ALTER DATABASE [DBName] SET ONLINE GO — Clean up DROP DATABASE [DBName] GO  

Read on »

Oracle database script with Windows PowerShell

If Oracle database is running on Windows environment, PowerShell would be a very good tool for automated scripting for the database such as monitoring or backup script. So the following script would be an example:   Add-Type -Assembly System.Data.OracleClient $connectionString = “Data Source=HOSTNAME:1521/SID; User ID=USERNAME; Password=PASSWORD” $connection = New-Object System.Data.OracleClient.OracleConnection($connectionString) $connection.Open() #$queryString = “SELECT db_link

Read on »

Automate backups of SSAS cubes

How to automate backups of SSAS cubes! This article provides how to automate backups of SSAS cubes using Windows PowerShell. 1. Create text files and scipts on C:\Scripts\ a. CubeList.txt EnterpriseDW TrackingDW ETLDW   b. Backup_SSAS.ps1 $ServerName=”localhost” $loadInfo = [System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.AnalysisServices”) | Out-Null ## Add the AMO namespace [Microsoft.AnalysisServices.BackupInfo]$serverBackup = New-Object ([Microsoft.AnalysisServices.BackupInfo]) [Microsoft.AnalysisServices.Server]$server = New-Object Microsoft.AnalysisServices.Server $server.connect($ServerName)

Read on »