Query execute() API goes for inifinite wait (Hang)

Hi
I am using BDB XML 2.4 in Fedora core-4. when I execute xquery update operation followed by FLWOR get query, the execute() API goes for infinite wait. We have tried setting NOWAIT flags to see if it waits for lock, but the program is in INFINITE wait (hang) state.
Below is the sample code and query I have used.
#include <dbxml/DbXml.hpp>
using namespace DbXml;
int
main(int argc, char **argv)
     std::string containerName = "myContainer.dbxml";
     std::string docFilename = "./NECB1.xml"; // the filename
     std::string queryString1 = "declare namespace SWI='SWI'; <getBulkResult> { let $i :=collection()//SWI:wmanIfBsOfdmaDownlinkChannelTable return ($i)} </getBulkResult>";
std::string queryString = "replace node collection()//SWI:wmanIfBsOfdmaDownlinkChannelTable/SWI:wmanIfBsOfdmaDownlinkChannelEntry[@ifIndex='2']/SWI:wmanIfBsOfdmaDownlinkCenterFreq with <SWI:wmanIfBsOfdmaDownlinkCenterFreq>3</SWI:wmanIfBsOfdmaDownlinkCenterFreq>";
     try {
          u_int32_t env_flags=DB_CREATE|DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_AUTO_COMMIT|DB_RECOVER|DB_INIT_TXN;
          DbEnv *clEnv = new DbEnv(0);
clEnv->open("/tmp",env_flags,0);
          XmlManager mgr;
          if (mgr.existsContainer(containerName))
               mgr.removeContainer(containerName);
          // Now it is safe to create the container
          XmlContainer cont = mgr.createContainer(containerName);
          u_int32_t cf =1000; //time out value in micro seconds
          clEnv->set_timeout(cf,DB_SET_LOCK_TIMEOUT);
          // All Container modification operations need XmlUpdateContext
          XmlUpdateContext uc = mgr.createUpdateContext();
          // Create the file input stream
XmlInputStream *myStream = mgr.createLocalFileInputStream(docFilename);
// Put the document in the container
cont.putDocument(docFilename, myStream, uc, 0); //TODO try without last parm(0)
          std::cout << "File loaded" << std::endl;
          // Querying requires an XmlQueryContext
          XmlQueryContext qc = mgr.createQueryContext();
          qc.setDefaultCollection(containerName);
          qc.setNamespace("SWI","SWI");
          std::cout << "update query " << std::endl;     
          XmlQueryExpression expr = mgr.prepare(queryString, qc);
          XmlResults res = expr.execute(qc);     //modify
          std::cout << "get query " << std::endl;     
          XmlQueryExpression expr1 = mgr.prepare(queryString1, qc);
XmlResults res1 = expr1.execute(qc);     //getbulk
          std::cout << "The query modify, '" << expr.getQuery() << "' returned " <<
          res.size() << " result(s)" << std::endl;
          XmlValue value;
          std::cout << "Result 1: " << std::endl;
          while (res.next(value)) {
               std::cout << "\t" << value.asString() << std::endl;
          std::cout << "The query 2 bulk , '" << expr1.getQuery() << "' returned " <<
res1.size() << " result(s)" << std::endl;
          XmlValue value1;
std::cout << "Result 2: " << std::endl;
while (res1.next(value1)) {
std::cout << "\t" << value1.asString() << std::endl;
     } catch (XmlException &xe) {
          std::cout << "XmlException: " << xe.what() << std::endl;
     return 0;
Sample output:
===========
[root@localhost santhosh]# ./query
File loaded
update query
get query
^C
Please let me know what could be the issue. Do I need to set any transaction related flags? I hope it should through exception if any setting/query is wrong.
Thanks,
Santhosh

Hi Santhosh,
Because you aren't using explicit transactions, your update query is being auto-transacted, and the read-only query is running without a transaction. This is very bad, and is giving you a self-deadlock situation. You should use an explicit transaction for your queries.
John

Similar Messages

  • When i try to submit an application with Application Loader, the wizard is blocked on "Send API itunes connect usage, waiting for response". Any idea ?

    When i try to submit an application with Application Loader, the wizard is blocked on "Send API itunes connect usage, waiting for response". Any idea ?

    Thank you, Vincent! It's still down for me, but at least I know someone had the same issue. Hoping it's going to work over here soon
    Best!

  • "db file scattered read" too high and Query going for full table scan-Why ?

    Hi,
    I had a big table of around 200mb and had a index on it.
    In my query I am using the where clause which has to use the
    index. I am neither using any not null condition
    nor using any function on the index fields.
    Still my query is not using the index.
    It is going for full table scan.
    Also the statspack report is showing the
    "db file scattered read" too high.
    Can any body help and suggest me why this is happenning.
    Also tell me the possible solution for it.
    Thanks
    Arun Tayal

    "db file scattered read" are physical reads/multi block reads. This wait occurs when the session reading data blocks from disk and writing into the memory.
    Take the execution plan of the query and see what is wrong and why the index is not being used.
    However, FTS are not always bad. By the way, what is your db_block_size and db_file_multiblock_read_count values?
    If those values are set to high, Optimizer always favour FTS thinking that reading multiblock is always faster than single reads (index scans).
    Dont see oracle not using index, just find out why oracle is not using index. Use the INDEX hint to force optimizer to use index. Take the execution with/witout index and compare the cardinality,cost and of course, logical reads.
    Jaffar
    Message was edited by:
    The Human Fly

  • Execute SQL Task - FOR XML PATH query error

    I have the following query
    SELECT pl.Id,
    pl.StartTime,
    pl.EndTime,
    pl.PackageName,
    pl.Computer,
    pl.Operator,
    CASE WHEN (CHARINDEX('stack trace', pl.ErrorDescription) > 0) Then
        SUBSTRING(pl.ErrorDescription, 0, CHARINDEX('stack trace', pl.ErrorDescription))
        ELSE
        pl.ErrorDescription
        END as ErrorDescription
    ISNULL(ErrorFile,'') as ErrorFile,
    'Not Applicable' as SourceSystem
    FROM etl.PackageLog as pl
    WHERE pl.Processed = 0
    ORDER BY pl.StartTime, pl.PackageName
    FOR XML PATH('Row'), ROOT(N'FieldingCounts')
    in a Execute SQL Task and i get the following error:
    [Execute SQL Task] Error: Executing the query "SELECT pl.Id,
    pl.StartTime,
    pl.EndTime,
    pl.Package..." failed with the following error: "An invalid character was found in text content.
    ". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    The query execute without problem in database and in the ssis package doens't run because of the column
    CASE WHEN (CHARINDEX('stack trace', pl.ErrorDescription) > 0) Then
        SUBSTRING(pl.ErrorDescription, 0, CHARINDEX('stack trace', pl.ErrorDescription))
        ELSE
        pl.ErrorDescription
        END as ErrorDescription
    Any help to overcome the problem?
    Thanks

    Hi,
    It looks like that you must be trying to set the result of the query to some variable from the Execute SQL Task. If yes, make sure that the target variable is of the correct data type where XML string  can fit into. Considering that in SSIS, we have
    some limit for XML strings.
    Please let me know if it doesn't help.
    Thanks,
    Nimit

  • Could not save the document to the repository for the following reason: [repo_proxy 30] DocumentFacade::uploadBlob - Query execute has failed : Error occurred while attempting to reconnect to CMS : Not a valid logon token. (FWB 00003) (hr=#0x80042a70) (WI

    Hi, getting Could not save the document to the repository for the following reason: [repo_proxy 30] DocumentFacade::uploadBlob - Query execute has failed : Error occurred while attempting to reconnect to CMS : Not a valid logon token. (FWB 00003) (hr=#0x80042a70) (WIS 30567) amongst lots of other errors when scheduling.
    I was logged in as administrator and attempting to schedule a webi document to my self using the email option.
    thanks in advance

    Hi Trinath,
    Could you please confirm if you could save a new report as well or not; or is it specific to scheduling.
    If you are unable to save a report also then I think this is due to the path of the Input File Repository Server or its temporary directory are not pointing to the same path, and their locations are set to 2 different hard drives
    BOXI3.1 Server must use the same hard drive (local or network share) for the Input File Repository Server and its temporary directory.
    - Shahnawaz

  • How can I do for a row of a query be data provider for a variable?

    Hi friends, I have a problem !
    How can I do for a row of a query be data provider for a variable?
    I need that a value of variable be stored when the user select a row in a query. At the BPS we can do this configuring the variable selector in WIB, and in a WAB how I can do this ?
    Best regards,
    Gustavo Liberado

    In this case when I press the key to call other forms I need to wait for the response in the secondary form and then process the result.That is exactly what a "modal JDialog" (or JOptionPane) are used for.
    Try it. Create a short demo program. All you need is a JFrame with a single button to show the modal dialog. All you modal dialog needs is a single button to close the dialog. After you show the modal dialog add a System.out.println(...) statement in your code and you will see that it is not executed until the dialog is closed.
    Then once you understand the basics you add the code to your real program.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • Query to track the holder and waiter info

    Hi All,
    I have framed the following query to get the blocker and holder info.
    I intend to use this query in a auto-generated mail which executes every 15 mins
    I have put an outer join on the holder because the holder DML might have completed its execution (v$sqlarea might not have info about this holder DML) at the time the auto mail configuration fires this query
    I am not a dba and was apprehensive if there is some mistake in the logic of my query.
    I was also expecting to join v$sql_bind_capture using sql_hash_value and sql_address just the way in which I have joined v$sqlarea
    Looking forward to your kind help in vetting the below query
    Select distinct waiting_session,
    dba_waiters.holding_session,
    decode(to_char(session_waiting_info.STATE),'0','waiter is currently waiting','-2','duration of last wait by waiter is unknown','-1','waiter waited for a short time',' waiter waited long time') "waiters waiting state",
    decode(session_waiting_info.WAIT_TIME,0,'waiter waiting') "waiters last wait time",
    decode(to_char(session_holding_info.STATE),'0','holder is currently waiting','-2','duration of last wait by holder is unknown','-1','holder waited for a short time','holder waited long time') "holders waiting state",
    decode(session_holding_info.WAIT_TIME,0,'waiter waiting') "holders last wait time",
    sql_waiting_info.sql_text "query of the waiter",
    sql_holding_info.sql_text "query of the holder",
    session_waiting_info.STATUS "waiting STATUS",
    session_holding_info.STATUS "holding STATUS",
    session_waiting_info.process "waiting process",
    session_waiting_info.PROGRAM "waiting PROGRAM",
    session_holding_info.process "holding process",
    session_holding_info.PROGRAM "holding PROGRAM",
    session_waiting_info.ROW_WAIT_OBJ# "waiting object",
    session_waiting_info.ROW_WAIT_ROW# "waiting row",
    session_holding_info.ROW_WAIT_OBJ# "holding object",
    session_holding_info.ROW_WAIT_ROW# "holding row",
    session_waiting_info.BLOCKING_SESSION_STATUS "waiting session status",
    session_holding_info.BLOCKING_SESSION_STATUS "holding session status",
    session_waiting_info.username "holding os username",
    session_holding_info.username "waiting os username",
    session_waiting_info.MACHINE "waiting MACHINE",
    session_waiting_info.TERMINAL "waiting TERMINAL",
    session_holding_info.MACHINE "holding MACHINE",
    session_holding_info.TERMINAL "holding TERMINAL",
    session_waiting_info.TYPE "waiting TYPE",
    session_holding_info.TYPE "holding TYPE"
    from dba_waiters,
    v$session session_holding_info,
    v$session session_waiting_info,
    v$sqlarea sql_waiting_info,
    v$sqlarea sql_holding_info
    Where dba_waiters.waiting_Session = session_waiting_info.sid
    and dba_waiters.holding_Session = session_holding_info.sid
    And session_waiting_info.sql_hash_value = sql_waiting_info.hash_value
    And session_waiting_info.sql_address = sql_waiting_info.address
    and session_holding_info.sql_hash_value = sql_holding_info.hash_value(+)
    And session_holding_info.sql_address = sql_holding_info.address(+)
    and dba_waiters.mode_held 'None'
    Regards,
    Vishal

    Hi Jonathan,
    I have tried to incorporate your suggestions in the below query. Please let me know about the problems that the below query suffers from
    select session_waiting_info.BLOCKING_SESSION,
         waiter.sid waiting_session,
         waiter.SECONDS_IN_WAIT,
         decode(session_holding_info.STATE,'WAITED SHORT TIME','Holder did not wait and is currently '||session_holding_info.STATUS,'WAITING','Holder is also waiting for the past '||session_holding_info.SECONDS_IN_WAIT ||' seconds','WAITED UNKNOWN TIME','Duration of last wait of holder is unknown','WAITED KNOWN TIME','Duration of last wait by the holder is:'||session_holding_info.STATE || ' and is currently '||session_holding_info.STATUS) "State of holder",
         sql_waiter_info.SQL_TEXT,
         bind_values.NAME,
         bind_values.VALUE_STRING,
         session_waiting_info.STATUS "waiting STATUS",
    session_waiting_info.username "holding os username",
    session_holding_info.username "waiting os username",
    session_waiting_info.STATUS "waiting STATUS",
    session_waiting_info.process "waiting process",
    session_holding_info.process "holding process",
    session_waiting_info.PROGRAM "waiting PROGRAM",
    session_holding_info.PROGRAM "holding PROGRAM",
    session_waiting_info.ROW_WAIT_OBJ# "waiting object",
    session_waiting_info.ROW_WAIT_ROW# "waiting row",
    session_holding_info.ROW_WAIT_OBJ# "holding object",
    session_holding_info.ROW_WAIT_ROW# "holding row",
         session_waiting_info.sql_id,
         session_waiting_info.SQL_CHILD_NUMBER
    from V$SESSION_WAIT waiter,
         V$SESSION session_holding_info,
         V$SESSION session_waiting_info,
         V$SQLSTATS sql_waiter_info,
         V$SQL_BIND_CAPTURE bind_values
    where waiter.sid = session_waiting_info.sid
    and session_waiting_info.BLOCKING_SESSION = session_holding_info.sid
    and session_waiting_info.sql_id = sql_waiter_info.sql_id
    and session_waiting_info.sql_id = bind_values.sql_id(+)
    and session_waiting_info.SQL_CHILD_NUMBER = bind_values.CHILD_NUMBER(+)
    and waiter.WAIT_TIME = 0
    Regrds,
    Vishal

  • How to get SQL statement from (Collection) query.execute();

    We have a JDO Persistence class ClassName that execute query using following code. After this statement get executed, record does not get updated in the DB. Is there a way to check what SQL statement got submitted in the (Collection) query.execute(); ??? <br><br>
    Extent extent = pm.getExtent(ClassName.class, false); <br>
    Query query = null; <br>
    try { <br>
    query = pm.newQuery(extent, filter); <br>
    Collection results = (Collection) query.execute();<br>
    Iterator i = results.iterator();<br>
    if (i.hasNext()) {<br>
    ...<br>
    }<br>

    You can always find out the names of tables that are views, using java.sql.DatabaseMetaData and its getTables() method.
    This tends to be a nice source of examples:
    javaalmanac.com
    However, if you're asking for the underlying SQL used to CREATE VIEW, I don't see anything in the API that will give you that. After all, JDBC shouldn't have to know if it's dealing with an ordinary table or a view. I think you'd have to ask your DBA for the underlying SQL.
    Once you have it, what do you plan to do with it?
    %

  • My iPhone 4s 5.1.1 won't let me download or update any apps it's starts by saying "waiting" downloads half way then goes back to "waiting" and then does it again then says it can't download or update help

    My I phone 4s 5.1.1 won't let me download or update anything it starts by "waiting" then loads half way n goes bak to "waiting" then does it against then it says that it's unable to download or update help please I've tried signing out of my apple account and signin back in I've reset all settings I've turned it off and on idk what else to do!!

    I have decided to dedicate this thread to the wonderful errors of Lion OSX. Each time I find a huge problem with Lion I will make note of it here.
    Today I discovered a new treasure of doggie poop in Lion. No Save As......
    I repeat. No Save As. In text editor I couldn't save the file with a new extension. I finally accomplished this oh so majorly difficult task (because we all know how difficult it should be to save a file with a new extension) by pressing duplicate and then saving a copy of the file with a new extension. Yet then I had to delete the first copy and send it to trash. And of course then I have to secure empty trash because if I have to do this the rest of my mac's life I will be taking up a quarter of percentage of space with duplicate files. So this is the real reason they got rid of Save As: so that it would garble up some extra GB on the ole hard disk.
    So about 20 minutes of my time were wasted while doing my homework and studying for an exam because I had to look up "how to save a file with a new extension in  mac Lion" and then wasted time sitting here and ranting on this forum until someone over at Apple wakes up from their OSX-coma.
    are you freaking kidding me Apple? I mean REALLY?!!!! who the heck designed this?!!! I want to know. I want his or her name and I want to sit down with them and have a long chat. and then I'd probably splash cold water on their face to wake them up.
    I am starting to believe that Apple is Satan.

  • Difference in Query generated by OBIEE for same report

    Hi,
    I am using a a report(X) in a filter condition.
    I am seeing a peculiar issue with OBIEE server. When i am running a report(X) alone, the query generated is different. But when i am using the same report in filter condition of other report(Y), the same report is generating some other query. The first report(X) is running fine but the second(Y) is not running at all.
    Case 1(Report X) Query: The report is breaking into 3 parts for different fact tables and combining the data to give result.
    Case 2(Report Y): A single query is being formed and within it is fecthing the data from different fact tables using subqueries.
    Case2 is creating a lot of problem as the performance is totally poor.
    Any suggesstions??
    Thanks
    Tataji

    Hi, we haven't debugged the application or traced the query against the production server (it's in our customer's office) buy I think there's no difference since the query itself has been tested using sqldeveloper against both servers (XE 11.2 and Enterprise 11.1) and the behavior is consistent. By consistent I mean:
    - The query executed via sqldeveloper against Oracle XE 11.2 runs ok and so does the application.
    - The query executed via sqldeveloper against Oracle Enterprise 11.1 fails with an ORA-01790 error, and so does the application (exceptions are being logged in the Event Log).
    To sum up: the same query runs ok in Oracle XE 11.2 and fails in Oracle Enterprise 11.1.
    Additional information: we have tried explicit casting the NULL literals to the corresponding data types (in the UNION ALLs) and the query works fine in both versions. ¿Is there an option in ODAC to tell the query generator to write this explicit castings?
    Regarding the DB schema and the LINQ query, I'll be sending them asap.
    Regards,
    Ernesto.

  • Query executes in RSRT but not in BEx Analyzer

    Hi Everyone,
    I have a query for an infocube and ods object, in the bex analyzer for the infocube the query executes which has around 5000 records but for the ods object which has also 5000 records comes up with this error.
    <b>An exception with the type CX_SY_EXPORT_NO_SHARED_MEMORY occurred, but was
    neither handled locally, nor declared in a RAISING                                                                               
    Message no. RS_EXCEPTION000</b> 
    when I execute the query in RSRT it comes up.
    After closing and re logging into bex analyzer executes the query for the first but for the second time again it throws up this error.
    What could be the problem? Can anyone please let me know. Its really really urgent.
    Thanks,
    Prashant.

    hi Prashant,
    try check in RSRT, after choose your query, click 'properties' and set cache mode to 'main memory cache without swapping'.
    also check oss note 656060-OLAP: Cache main memory displacement not functioning.   
    hope this helps.
    Symptom
    Although one of the following two cache modes
    Main Memory Cache Without Swapping (mode 1)
    Main Memory Cache With Swapping (mode 2)
    is set for a query, long runtimes occur when you execute the query. The statistics (table RSDDSTAT) display the database times.
    If there is a heavy system load, the following message can also appear: RS_EXCEPTION000: No left space in shared memory.
    Other terms
    Cache, performance, displacement, shared buffer
    Reason and Prerequisites
    This problem occurs because the shared memory is insufficiently dimensioned.
    <b>Solution</b>
    Increase the amount of shared memory. The size of the shared memory should be at least 200 MB. You can refer to transaction RSRCACHE for the amount of memory reserved by the main memory cache (RSRCACHE -> Main Memory: Shared Memory/Buffer Reserved).
    The corresponding settings are (at least):
    rsdb/esm/buffersize_kb = 200000
    and, as a precaution, also
    rsdb/esm/max_objects = 10000.
    Alternatively, for queries with large resulting quantities, you can convert the Cache Mode in transaction RSRT1 to
    Cluster/Flat File Cache for Each Application Server (mode 3)
    Cluster/Flat File Cache Across Each Application Server (mode 4)

  • Function module going for DUMP

    Hi ALL,
    I have import request and i got sucess .My 3 function modules are import to client system.2 FM are working properly but 1 function module is going for DUMP.
    When iam Executing this FM through SE37 F8 its running but iam not able to display or change this ZFM.
    In our DEV sytem it is working properly.but Client system it is going for DUMP.
    I have gone dump analysis its saying
    An exception occurred. This exception is dealt with in more detail below
    . *The exception, which is assigned to the class 'CX_SY_IMPORT_MISMATCH_ERROR',
    was neither caught nor passed along using a RAISING clause, in the procedure
    MO_IMPORT_MODIFICATIONS" "(METHOD
    Length error occurred during the IMPORT statement
    *The system found when importing that the target object was longer or
    shorter than the object to be imported*
    Thanks in Advance,
    Madhu.
    Edited by: madhubabu rao on Apr 23, 2009 10:34 AM
    Edited by: madhubabu rao on Apr 23, 2009 10:36 AM

    Hi sekhar,
    I did not transport individually.I have transport 3 FM in a function group and it is assigned to a Package.
    First i have 2 FM in my function group after that i have copied one more FM from another Function group.
    in SE80 right click -->copy it asked me function group name only .not transport number.
    After copy the FM i have transport total package.2 FM are working properly .The FM which i have copied it is not able to display or edit.
    Madhu

  • Starting a Web Application out of WAD from menue "Query/Execute" ...

    Dear colleagues,
    starting a Web Application (let's say its the template "BTMP_001") out of the Web Application Designer from menu "Query/Execute" starts the Web Query Analyzer instead of the Template "BTMP_001".
    The URL looks like: http://<xxxxx>.<yyyyyy>.<zzzzzz>.com:<Port>/irj/servlet/prt/portal/prtroot/pcd!3aportal_content!2fcom.sap.pct!2fplatform_add_ons!2fcom.sap.ip.bi!2fiViews!2fcom.sap.ip.bi.bex?TEMPLATE=BTMP_001&DUMMY=0
    Does somebody have any hint? Why I allways get the Web Query Analyzer althoug the end of the URL shows the technical name of my web application?
    Thanks for any help!
    op

    Problem solved!

  • Call for adobe form is going for dump for multiple users

    hi,
    i am calling an adobe form in a program i.e. for multiple users. now my problem is.....
    3 people are using same tcode to generate the adobe form output for different data. but when they click at a time on the button to generate the adobe output, then adobe form is coming for only one user and it is going for dump for other users.
    and this dump is coming because of exception "CX_FP_API_INTERNAL" in funtion module FP_FUNCTION_MODULE_NAME which i am using to get the function module name of the adobe form in my program.
    can u please give me some solution to rectify this issue....

    That's nothing!
    An engineer and I contacted Adobe technical support by phone to ensure the PC I was having custom built was configured to its optimum. They advised XP64 as the best operating environment. After that discussion we had to completely revise procurement, etc to get the bits and compatible XP64 compatible software, putting the build project back a few weeks as well, Imagine how I laughed when I found out on one of these forums that XP64 is the worst choice and totally unsupported by CS4!
    I have written to Shantanu Narayen, Adobe CEO and didn't even get an acknowledgement I raised this last week on the Adobe stand at BVE and was told they'd get someone to contact me asap but guess what, niet...! To be fair there has been one Adobe executive that recognises the problem and the damage poor customer support is causing the company; he has been as helpful as he can. Unfortunately, it seems the overall Adobe culture at the top is "get the money and run". If your problem goes beyond what's already on their web pages, tough luck!
    Regards,
    Graham

  • How do i get a output in CSV of a SQL query executed via SQL Command prompt

    Hi All,
    I have a question with reference to SQL command prompt. I have a sql query which runs properly and gives proper execution in SQL Management console in GUI.
    This report is used to pull the free disk space report of our servers
    As i want to schedule it as a report so i want to script it to run via SQL command prompt. I made the script and it works fine if i enter it in SQL command prompt. When i try to extract the output to a CSV File it fails. Below is the details of the command
    i am using to query to pull the data. Can anyone help me in getting the output of this query in SQL command prompt.
    sqlcmd -W -s , -S Servers FQDN
    use operationsmanager
    Go
    Query:"select Path, InstanceName, SampleValue 
    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
    where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
    order by countername, timesampled" -s "," -o "C:\DataSqlCmd.csv"
    Go
    When i enter the command without the quotes when the query is starting and ending and also without the output command (-s "," -o "C:\DataSqlCmd.csv") it is working and shows the output in the command prompt. Below is the screen shot for
    your reference.
    Due to security reasons i have to erase the server names:
    But when i add the line to extract the output ( -s "," -o "C:\DataSqlCmd.csv") It gives me this error:
    The exact command would be:
    sqlcmd -W -s , -S CINMLVSCOM01.e2klab.ge.com
    use operationsmanager
    Go
    "select Path, InstanceName, SampleValue 
    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
    where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
    order by countername, timesampled" -s "," -o "C:\DataSqlCmd.csv" -h-1
    Go
    saying the syntax is not correct or some thing as per the below screenshot.
    Can any one please help. Below is just the query whi i use to get the output in SQL management studio.
    Can any one make a command for the below quer so i can directly execute and test for getting the output.
    select Path, InstanceName, SampleValue 
    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
    where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
    order by countername, timesampled
    Gautam.75801

    Can you try the below query?
    select Path, InstanceName, SampleValue
    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
    where SampleValue < 20 and CounterName like '% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
    order by countername, timesampled
    -- replace the below query part in the below SQLCMD C:\>SQLCMD -S SERVERNAME -E -d operationsmanager -Q "select * from sys.databases ds with (nolock) where name='master'" -s "," -o "F:\PowerSQL\MyData.csv" -h -1
    SQLCMD -S SERVERNAME -E -d OperationsManager -Q "select Path, InstanceName, SampleValue
    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
    where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
    order by countername, timesampled" -s "," -o "c:\MyData.csv" -h -1
    Refer for the other ways 
    http://dba.stackexchange.com/questions/23566/writing-select-result-to-a-csv-file
    --Prashanth

Maybe you are looking for