Smo.Server.ExecuteNonQuery throw an error executing a script with IF statement

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.!

Olaf
Helper answer does make sense and you won't be able to modify database which doesn't exists. However, your syntax's are correct.
However, if you are executing it via Powershell as mentioned by HoroChan then
I recommend you to increase the statementTimeout to appropriate value. 
There may be chances that alerting database got hanged and exceeded the timeout.  So instead of IMMEDIATE ROLLBACK you can use
WITH NO WAIT
From MSDN:
Specifies that if the requested database state or option change cannot complete immediately without waiting for transactions to commit or roll back on their own, the request will fail.
So your overall code will look like 
USE MASTER;
IF EXISTS(select * from sys.databases where name = 'dbname')
ALTER DATABASE [dbname] SET OFFLINE WITH NO_WAIT
GO
Hope this will help.

Similar Messages

  • HFM 933, error executing vb script %0 (for rules file)

    i have a HFM rules file that is error-free, but sometimes, when i run a consolidation via SmartView, it is aborted and the error is "Error Executing VB Script %0".
    Does anyone know why this occurs?
    Thanks in advance.

    The error message you shared may not have anything to do with HFM rules. There are a number of things that can generate a VBScript error: HFM rules, HFM custom member lists, or permissions problems/configuration problems with IIS. Smart View uses IIS, so maybe this is a configuration issue there. If you log out and log back in again, perform the very same activity successfully, it could mean you have load balance problem, or some other network related error. If it's a permission problem on the server, it will affect all users in the same way. An HFM member list problem would reveal itself any time the member list is called: whether through HFM's forms, grids, smart view, or Reports.
    --Chris                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Error executing a query with large result set

    Dear all,
    after executing a query which uses key figures with exception aggregation the BIA-server log (TrexIndexServerAlert_....trc) displays the following messages:
    2009-09-29 10:59:00.433 e QMediator    QueryMediator.cpp(00324) : 6952; Error executing physical plan: AttributeEngine: not enough memory.;in executor::Executor in cube: bwp_v_tl_c02
    2009-09-29 10:59:00.434 e SERVER_TRACE TRexApiSearch.cpp(05162) : IndexID: bwp_v_tl_c02, QueryMediator failed executing query, reason: Error executing physical plan: AttributeEngine: not enough memory.;in executor::Executor in cube: bwp_v_tl_c02
    --> Does anyone know what this message exactly means? - I fear that the BIA-Installation is running out of physical memory, but I appreciate any other opinion.
    - Package Wise Read (SAP Note 1157582) does not solve the problem as the error message is not: "AggregateCalculator returning out of memory with hash table size..."
    - To get an impression of the data amount I had a look at table RSDDSTAT_OLAP of a query with less amount of data:
       Selected rows      : 50.000.000 (Event 9011)
       Transferred rows :   4.800.000 (Event 9010)
    It is possible to calculate the number of cells retreived from one index by multiplying the number of records from table RSDDSTAT_OLAP by the number of key figures from the query. In my example it is only one key figure so 4.800.000 are passed to the analytical engine.
    --> Is there a possibility to find this figure in some kind of statistic table? This would be helpful for complex queries.
    I am looking forward to your replies,
    Best regards
    Bjoern

    Hi Björn,
    I recommend you to upgrade to rev 52 or 53. Rev. 49 is really stable but there are some bugs in it and if you use BW SP >= 17 you can use some features.
    Please refer to this thread , you shouldn't´t use more than 50% (the other 50% are for reporting) of your memory, therefor I have stolen this quote from Vitaliy:
    The idea is that data all together for all of your BIA Indexes does not consume more then 50% of total RAM of active blades (page memory cannot be counted!).
    The simpliest test is during a period when no one is using the accelerator, remove all indexes (including temporary) from main memory of the BWA, and then load all indexes for all InfoCubes into ain memory. Then check your RAM utilization.
    Regards,
    -Vitaliy
    Regards,
    Jens

  • How to execute vb script with out using Remote manager in oim 11g r2

    Hi Currently,
    i have a requirement to execute  vb script (present on a remote machine in which connector server is installed) from oim machine while using Exchange connector (11.1.1.6).
    This can be achieved by using remote manager,but i dont want to use remote manager.
    Hence decided to use Action scripts.
    As per connector configuration,
    i have configured Action scripts in Lookup.Exchange.UM.Configuration lookup definition, by means of three entries
    After Create Action Language      Shell
    After Create Action Target           Resource
    After Create Action File              /home/scripts/Disable.bat
    Disable.bat has the following ,
    Powershell.exe -File C:\scripts\Setup.vbs
    -%Log on Name%
      Exit
    As Setup.vbs is expecting a parameter of log on name, i was providing the same.
    But while creating the user,as this script gets called, getting the following error and hence 'create User' is getting failed.
    Problem while PowerShell execution System.Management.Automation.RemoteException: This task does not support recipients of this type. The specified recipient XXXXXXXXXXX...XXXXX is of type UserMailbox. Please make sure that this recipient matches the required recipient type for this task.
    While provisioning the user to Exchange , i have selected 'Recepient type' as 'User Mail box' explicitly, but still getting the error.
    Please provide any pointers to resolve the issue.
    Thanks in advance
    Kumar

    As far as I know Oracle and MySQL are two different products.
    Why do you clutter an Oracle forum with MySQL questions?
    If MySQL is such a tremendous RDBMS, like many people state (as 'free' means per definition better),
    why don't you visit a MySQL forum where fellow MySQL aficionados can answer you MySQL questions?
    In short, why don't you stop abusing Oracle forums?
    Sybrand Bakker
    Senior Oracle DBA

  • Executing sql scripts with command line Sql plus

    Hello
    Well I will be gradefull if I have an answer to the follow questions
    a) How can I connect to a remote XE using sqlplus (command line)?
    for example I'm trying to connect like this : sqlplus sys/syspassw@//remoteserver:1521/xe
    and I get responce from server that I have to connect as SYSDBA or SYSOPER, so what is the proper syntax in this case?
    b) I want to execute a script file with DDL commands from Windows conscole using sqlplus. Inside this script I have the connect command and others. Is there a way to pass the name of script file as parameter to the sqlplus and execute it ? If yes what is the proper syntac from command line of Windows?
    Thank you

    There are two ways to do that...
    Either use the spool command in sqlplus, or on your command line calling sqlplus use a >> to direct the output to a file. Usually the spool is cleaner.
    It goes like this:
    spool C:\logfile.txt
    {sql commands here}
    spool off
    or
    sqlplus /nolog @sqlfile.sql >> C:\logfile.txt
    The output will be formatted slightly differently, and if you use the DOS method you won't be able to see the output as it's running.
    ~Jer

  • Exchange server keeps throwing "Syntax error in Ping command request. (status 4)" for Ping

    We have exchange activesync client on Android. For some users, the exchange server sometimes responds with
    "Syntax error in Ping command request. (Status 4)"
    or
    "The Ping command request omitted required parameters. (status 3)"
    We logged the request we are sending and there does not seem to be anything wrong.  We could have collected server logs, but this issue happens only for some customers and customers are not comfortable collecting and sending us logs.
    Many times, it recovers and we stop getting the error after some time. But, for few users it never recovers.
    We need to yet collect the exchange server version.
    What is the best way to recover from such an error? (Sync?). We observed sometimes that if we send the same sync multiple times, server throws error "Identical Sync requests".
    Please help.

    Look at the two config files:
    /Library/Preferences/edu.mit.Kerberos
    /var/db/krb5kdc/kdc.log
    the Database is locked or in use message is due to a missing lock file.
    Look in /var/db/krb5kdc/ for principal.kadm5.lock
    Hope this gets you started
    - Leland

  • Throws severe error in OBIEE SA with Essbase Cube as Source

    Hi All,
    Currently we built the SA using Essbase ASO cube as source.Wehen we are trying to drag more then 4-5 dimension hierarchies it throws an severe error
    Essbase Error: Query is allocating too large memory(>4GB) and cannot be executed.Query allocation exceeds allocation limits(HY000)
    I am not able to identify the same in Essbase Excel addin.All are single-level based hierarchies and the count of dimensions is not more than 1000.
    Can someone help me out to find out a way to resolve this issue or any work around.
    Thanks,
    SatyaB

    What is the version that you using for OBIEE and Essbase ?? This is a know bug when Essbase as a source is used for OBIEE reporting. Try to get in touch with Oracle Support by raising an SR and getting correct patch (set of library files) for your system.
    This shud solve your problem.

  • Unexpected syntax error executing MDX sentence with a "LIKE" predicate

    Hello,
    I am executing the next MDX sentence correctly on a SAPBW server
    SELECT NON EMPTY
              FILTER (
                   [0VENDOR].[LEVEL01].MEMBERS ,
                   [0VENDOR].CURRENTMEMBER.PROPERTIES("MEMBER_CAPTION") LIKE "V01*"
         DIMENSION PROPERTIES [0VENDOR].[20ADDR_NUMBR], [0VENDOR].[20CITY_2] ON ROWS,
         {[Measures].[0NUMDAY], [Measures].[0RSPL_FCPER]}  ON COLUMNS
    FROM [$MY_CUBE]
    The MDX is working OK and returning all members that their caption start by "V01".
    The problem appears when I execute the query in another SAP server. This new server is returning the next syntax error.
    Syntax error: Syntax Error : ....CURRENTMEMBER.PROPERTIES("MEMBE, row 113, item: 113
    I was searching about SAP and MDX, LIKE operator, the syntax error... but I did not find any interesting.
    Why this query could fail in a certain SAP server but work OK in another?
    I tried to change the FILTER condition with a "=" operator and it works OK, but I need the "LIKE" one.
    Thanks in advanced.

    Thanks for your response.
    The MDX query works OK at SAP 7.0SP1, but it does not work at SAP 7.3.1SPS5.
    Yes, all attributes are the same and exists, and query was tested also with MDXTEST transaction. At this transaction, the error was the same "Syntax error: Syntax Error : ....CURRENTMEMBER.PROPERTIES("MEMBE, row 11" ...
    Note that is a parsing error and it happens parsing the left part of the "LIKE" predicate, so I do not think that attributes were important on this, no?

  • Executing multiple scripts with error reporting where necessary.

    Hi,
    I'm a developer using SQL developer to create scripts for Tables / Views / Procs. I'm relatively new to Oracle, as I've been using SQL server mostly. So please bear with me.
    Now, the dev team constantly upset the dba due to subtle syntax issues between SQL Developer and SQL+. So, what we are now meant to do is test our scripts via SQL+ on the understanding that if it works with that it's good.
    However, you DBAs know that developers don't always do what they are told :).
    Hence, I have been tasked each morning to run all the scripts to make sure they are ok.
    I know I can execute multiple scrips easily like this....
    @c:\Scripts\Table1
    @c:\Scripts\Table2
    @c:\Scripts\Proc1
    @c:\Scripts\Proc2
    etc
    However, this seems to echo all the contents of the scripts in the output window. So it's a bit of a task to trawl through the output to see if there are any errors.
    What I would really like to do is as above, but rather than echoing the script contents, just provide output to say that each object (tables / views / procs) has been created correctly, or if an error occurred, output the relevant object name and the error.
    eg - If Table2 DDL has errors, output along the lines of....
    Table1 created successfully.
    Error creating Table2: <Invalid data type>
    Proc1 created successfully.
    Error creating Proc2:<Object Table2 does not exist>
    Is this possible?
    Example pretty please.
    Ultimately, I'd like to email the output automatically - however, that's a task for another day :).
    Many thanks
    DC

    I'm not sure what you mean by "echo all the contents of the scripts in the output window". If I create a script a.sql
    drop table a;
    create table a ( col1 number );
    drop table b;
    create table b ( col1 number );
    drop table c;
    -- Note the error in the definition of c
    create table c ( 123 number ); and run it in a vanilla SQL*Plus session, I get the output you appear to be looking for
    SQL> @c:\temp\a.sql
    Table dropped.
    Table created.
    Table dropped.
    Table created.
    drop table c
    ERROR at line 1:
    ORA-00942: table or view does not exist
    create table c ( 123 number )
    ERROR at line 1:
    ORA-00904: : invalid identifierAre you looking for something different? Or are you getting different results?
    Justin

  • Error: Executing OWB Scripts Outside the OWB Tool

    We aim to extract OWB scripts (ddls, pl/sql, etc) and run them outside of the OWB tool in Beta and Production.
    Thus far, we’re able to execute ddls and compile OWB generated pl/sql procedures. We’re encountering errors on all attempts to execute the pl/sql code outside of OWB.
    Package created.
    Package body created.
    SQL> execute RECORDED_MEDIA_MAP;
    BEGIN RECORDED_MEDIA_MAP; END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00221: 'RECORDED_MEDIA_MAP' is not a procedure or is undefined
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Based on previous discussions with Oracle Sales Rep., we were under the impression that this could be done.
    Can OWB generated pl/sql execute outside of the tool? If so, what are the steps?
    Thanks,
    Carol-Ann

    OWB generates mapping as package of procedures. This package has the only external procedure/function (depend on OWB version: 9.2.0.4 - function, prev. releases - procedure).
    So, mapping that you have deployed could be executed by the following code (as for 9.2.0.4 version of OWB):
    DECLARE
    l_res NUMBER;
    l_env WB_RT_MAPAUDIT.WB_RT_NAME_VALUES;
    BEGIN
    l_res := MAP_PACKAGE.MAIN(l_env);
    END;

  • Error executing shell script using dbms_scheduler

    I have a job running which executes a shell script,which fails with following error :
    SQL> SELECT additional_info
    2 FROM user_scheduler_job_run_details
    3 WHERE log_date = (SELECT MAX (log_date)
    4 FROM user_scheduler_job_run_details);
    ADDITIONAL_INFO
    ORA-27369: job of type EXECUTABLE failed with exit code: No such file or directory
    STANDARD_ERROR="mkdir: Failed to make directory "/export/home/bwsolaris/abc"; Permission denied"
    This are contents of my shell script
    #!/bin/ksh
    /bin/mkdir /export/home/bwsolaris/abc
    Can anyone suggest me some way out of it?
    Thanks in advance!!!

    Does oracle still creates a user nobody"nobody" is a "standard" Unix/Linux lowly privileged user, which is used by DBMS_SCHEDULER by default.
    You should change permissions on /export/home/bwsolaris, e.g.
    $ chmod 777 /export/home/bwsolaris
    or use a different directory, where everyone has access, for example /tmp.
    Or take a look at Metalink Note:391820.1 - Scheduled Job Running Shell Script Fails With ORA-27369

  • Compilation error in jsp script with weblogic 9.1 server

    Hi All,
              i am using weblogic 9.1 compiler to compile my jsp code.
              it gives me compilation error.
              The root cause of the error is %% which comes in the code.
              for e.g take this code:-
              <%
              System.out.println("%%abc");
              %>
              this code will give error while error.
              here it is identifing %% as termination tag!
              same code works in tomcat & weblogic 8.1
              can anyone give any information in this regard.
              Reagrds
              Rahul

    I am also getting the same error. If you have solved this issue please share the solution.
              Thanks,
              Dikshit

  • Error executing connection method with WS- wsdl

    Good day.
    I need a little help.
    I have some problem running the access procedure to the web service mapped on my WDJ.
    I did all the procedure for use ro wsdl, did the mapping of the fields in my context.
    after it was run method to send the connection parameters.
    But when running:
    wdContext.currentConsultaSincronaElement().setChaveAcesso("XXXXXXXX-4487-4AE6-A41E-10F7808AYYYYYYY");
    Is the error below:
    java.lang.NullPointerException: while trying to invoke the methodnet.mdm.bp.wd.search.wd.comp.mastercompnew.wdp.IPrivateCreateFirstCompView$IConsultaSincronaElement.setChaveAcesso(java.lang.String) of a null object returned from
    net.mdm.bp.wd.search.wd.comp.mastercompnew.wdp.IPrivateCreateFirstCompView$IContextNode.currentConsultaSincronaElement()
    What can be happening? The mapping is correct with the fields of WS.
    Already checked one by one.

    hi carlos,
    have you checked the collection cardinality of your input context?
    the generated/Initial value is 0..1. so your currentNodeElement is probably null.
    if so - set the value to 1..1 and try it again.
    regards,
    christian

  • Error in R script with lubridate package

    Hello AK,
    I have corrected the code as you can see below but I am experiencing some issues :  
    Error 0063: The following error occurred during evaluation of R script:
     ---------- Start of error message from R ----------
     'to' cannot be NA, NaN or infinite
     'to' cannot be NA, NaN or infinite
     ----------- End of error message from R ----------
    ****the code***
    ## Map 1-based optional input ports to variables
    winData1 <- maml.mapInputPort(1) # class: data.frame
    install.packages("src/ggplot2_1.0.0.zip", lib = ".", repos = NULL, verbose = TRUE)
    install.packages("src/lubridate_1.3.3.zip", lib = ".", repos = NULL, verbose = TRUE)
    library(ggplot2, lib.loc=".", verbose=TRUE)
    library(lubridate, lib.loc=".", verbose=TRUE)
    withCallingHandlers({
        print(dmy_hm("01/01/2002 00:00"))
        print("done")
    }, warning=function(w) {
        message("handled warning: ", conditionMessage(w))
        invokeRestart("muffleWarning")
    winData1$date_time<-dmy_hm(paste(winData1$DATE, winData1$Time))
    ggplot(winData1, aes(date_time, AnemSD40aMS)) + geom_point() + geom_line()
    # Select data.frame to be sent to the output Dataset port
    maml.mapOutputPort("winData1");
    Pls I need your help on this.
    Thank you.

    I'm not sure what the purpose of your withCallingHandlers() call is, you are not guarding any code that is useful - if it happens, it'll also happen outside and you won't catch it. If it doesn't happen, you don't need it.
    There is no need to install.packages() ggplot2, it's preinstalled - just use library(ggplot2)
    Can you please post the full output log? it looks like something in your script isn't the size/shape you think it is.
    If you str(winData1) in your script before doing the above we can help by looking at the structure
    Regards,
    AK

  • How to execute SQL scripts with MaxDB ..?

    Hi all,
    i got some clue from another thread and i observed the command is like
    sqlcli -d DBNAME -u SQLUSER,SQLPASS -i filename.sql -c <delimiter> is there,
    when i use this the only first query is successfully executing,
    this might be problem with delimiter.
    can any body help how to use delimiter in the script file with an example.
    thanks in advance.
    --Hari

    Hi,
    Sample Script
    CREATE TABLE city
    (zip                CHAR (5)    KEY CONSTRAINT zip BETWEEN '10000' AND '99999',
    name               CHAR(20)    NOT NULL,
    state              CHAR(2)     NOT NULL)
    CREATE TABLE customer
    (cno                FIXED (4)   KEY CONSTRAINT cno BETWEEN 1 AND 9999,
    title              CHAR (7)    CONSTRAINT title IN ('Mr', 'Mrs', 'Company'),
    firstname          CHAR (10)   ,
    name               CHAR (10)   NOT NULL,
    zip                CHAR (5)    CONSTRAINT zip BETWEEN '10000' AND '99999',
    address            CHAR (25)   NOT NULL,
    FOREIGN KEY (zip) REFERENCES city ON DELETE RESTRICT)
    \dt customer
    COMMIT
    Regards
    Ayyapparaj

Maybe you are looking for

  • Crystal Reports 5 and Password

    Post Author: Avelina CA Forum: Crystal Reports Hello, I have an application wrote in VB with Access 2.0. In some pc's where I install it when I try to use a CR5 report ask me for the user id and password database, when I never have use password in th

  • Zen Micro headphone plugin probl

    I'm not very sure whether this should be posted in this forum, but this is the second time that this problem occured, my zen micro gives me distorted sounds when playing music, and I have to push back the plugin where the earphone and the zen is conn

  • Facebook App - cant see friends friends

    I am unable to see my friends friends on Facebook. When a friends page loads I see the icon for friends but once the page fully loads the friends icon disappears. I have tried to logging off and logging back on. I have removed the Facebook app twice

  • J2EE performance problem?

    hi,all friends I have a question as following. A J2EE application is running normally. When the client number increases a little , the performance decreases much. Why? Thank you all in advance. --blanka                                                

  • Win2008 x64 installation problem

    I have been fighting with installing Weblogic 10.3.5 on a Windows Server 2008 x64 machine. Before that I had no problems with installing 12.1.1 on the same machine, but I had to roll back to the previous version, so I uninstalled it. I use jrockit-jd