I am trying to executed this script (see below) using Smo libraries with powershell (this script works in SSMS)
use master;
GO
use master;
if (not exists(select * from sys.databases where name = 'dbname'))
alter database [dbname] set offline with rollback immediate;
GO
however, I always got an
Exception calling "ExecuteNonQuery" with "1" argument(s): "An exception occurred while executing a Transact-SQL statement or batch."
if I delete the if statement, the script execute without erros... is there any problem to use if statements? I would really appreciate any help
regards.!
- Edited by insdevelopment Wednesday, April 22, 2015 1:47 AM forget additional info