NOT IN sql querry

Hi
I had two tables
--USER LEVEL CATALOG TABLE
create table user_cat
(user_id number,
catloag_name varchar2(40),
catalog_id   number,
item_id      number );
Insert into USER_CAT (USER_ID, CATALOG_NAME, CATALOG_ID, ITEM_ID)
Values (1, 'DELL', 12, 1001);
Insert into USER_CAT (USER_ID, CATALOG_NAME, CATALOG_ID, ITEM_ID)
Values (1, 'DELL', 12, 1002);
Insert into USER_CAT (USER_ID, CATALOG_NAME, CATALOG_ID, ITEM_ID)
Values (1, 'NOKIA', 13, 1003);
Insert into USER_CAT (USER_ID, CATALOG_NAME, CATALOG_ID, ITEM_ID)
Values (1, 'NOKIA', 13, 1004);
Insert into USER_CAT (USER_ID, CATALOG_NAME, CATALOG_ID, ITEM_ID)
Values (2, 'DELL', 12, 1001);
Insert into USER_CAT (USER_ID, CATALOG_NAME, CATALOG_ID, ITEM_ID)
Values (2, 'DELL', 12, 1010);
Insert into USER_CAT (USER_ID, CATALOG_NAME, CATALOG_ID, ITEM_ID)
Values (2, 'HP', 11, 1011);
Insert into USER_CAT (USER_ID, CATALOG_NAME, CATALOG_ID, ITEM_ID)
Values (2, 'HP', 11, 1012);
Insert into USER_CAT (USER_ID, CATALOG_NAME, CATALOG_ID, ITEM_ID)
Values (2, 'HP', 11, 1014);
COMMIT;
--Catalog Level  Exclusion Table  which should not contains the USER_ID
--This table contains the records needs to be excluded .
create table cat_exclusion
( catalog_nam varchar2(40),
  catalog_id number ,
item_id  number);
SET DEFINE OFF;
Insert into CAT_EXCLUSION
   (CATALOG_NAME, CATALOG_ID, ITEM_ID)
Values
   ('DELL', 12, 1001);
Insert into CAT_EXCLUSION
   (CATALOG_NAME, CATALOG_ID, ITEM_ID)
Values
   ('NOKIA', 13, 1004);
Insert into CAT_EXCLUSION
   (CATALOG_NAME, CATALOG_ID, ITEM_ID)
Values
   ('NOKIA', 13, 1003);
COMMIT;
Now in the CAT_EXCLUSION table  I excluded the below records
For USER 1
-- DELL   12 1001
-- NOKIA 13 1004
AND for user 2 I excluded
--NOKIA 13 1003
Now i want to get the all other records for USER_ID =2 except for the excluded records.
I tried to do this using NOT IN below as shown but it was also excluding the other values.Please let me know how can we do this ?
Select   USER_ID
       , CATALOG_NAME
       , CATALOG_ID
       , ITEM_ID
  From   user_cat
Where   item_id Not In (Select   item_id From cat_exclusion)
    And  user_id = 2

You have to be careful about using NOT IN (SELECT...)
If one of the rows in the subquery is a null, you won't get any rows at all:
SQL> create table t as select * from dba_objects;
Table created.
SQL> create table s (object_type varchar2(30));
Table created.
SQL> insert into s values ('TABLE');
1 row created.
SQL> insert into s values ('INDEX');
1 row created.
SQL> insert into s values (null);
1 row created.
SQL> commit;
Commit complete.
SQL> select count(*)
  2  from   t
  3  where  object_type not in (select object_type from s);
            COUNT(*)
                   0
SQL> select count(*)
  2  from   t
  3  where  object_type not in (select object_type from s WHERE OBJECT_TYPE IS NOT NULL);
            COUNT(*)
               69505

Similar Messages

  • How to create services for sql querry with joint 2 tables ?

    Hi all,
    I start to learn the php services function for mysql querry in flex 4.5 and all seam to be ok.
    But i don't find anny help or tutorial to create service that call a sql querry with joint to tables, like this :
    Select table01.fieldA table02.fieldA WHERE table01.fieldC LIKE table02.fieldC
    Are there a way to do that in flashBuilder creation services interfaces, or not ?
    Does we make a special value Object and all the AS3  classes and not use the template opperations ?
    Thank's for your help or link
    fbm

    Hi Fabien,
    I'm afraid you'll have to learn a bit more about PHP...
    Joined tables is a relational database feature. It has nothing to do with PHP, and PHP has nothing to do with Flex...
    The "magic" of the flex framework is that it can plug itself into any backend (.Net, Java, PHP...)
    The new way Flash Builder interacts with PHP is through AMF (Actionscript Messaging Format) with the help of Zend and Zend_Amf. You've been able to do it on your own for a while, but it was a bit tricky to set up... The new IDE helps you doing those mapping with wizards. What it does is that it serializes and deserializes objects from PHP to Actionscript, and also generates Actionscript value objects.
    So what you'll have to do is to write your own PHP services to retrieve your data from joined tables in MySQL. Those services will return simple arrays. Then start the wizard, select your services. Flash Builder will then map the objects contained in the PHP arrays into Actionscript typed objects.
    I suggest you have a deep look into Zend_Tables...
    Hope it'll help.
    Julien.

  • Get sql querry from oraclecommand

    hello,
    i am using the oraclecommand with parameters to send a sql-query (for example: SELECT DOCID FROM SEARCHDOCUMENTS WHERE URL = :URL). Is there a chance to get the sql-querry whiich is executen on the oracle-server (for example: SELECT DOCID FROM SEARCHDOCUMENTS WHERE URL = 'http://www.oracle.com')?
    greetings
    jens

    Hi Jens,
    ODP tracing does not expose the bind values, you can get the value sent from the provider on the client with SQL NET tracing or you can turn on SQL Trace at a level that includes binds for the session you are interested and get the information that way.
    HTH
    Jenny B.

  • To use SQL or to not use SQL ..... That is the question

    A couple of posts lately have brought something to my attention that I wanted to discuss between the folks that view this forum because I believe it is important. I highly value the opinions of many of the members here so I think getting your insight would not only benefit me, but many other forum members as well.
    This discussion stems from two posts:
    {message:id=3786432} (Billy)
    ...The question that you need to ask yourself is why use such a technique? For rendering the data a specific way in the client? Well, rendering data is NOT a SQL function and in essence a result of ignorance of how to correctly use client-server. Rendering on the client is dealt with by the client itself. Using SQL to do it.. not only nasty (as many of these examples above are), but also far from optimal and efficient SQL. And in most cases, will not scale. Increase the data volume of the table queried and there will be a hefty performance knock as SQL is incorrectly used.
    ...>
    {message:id=3914362} (Sven W.)
    ...For the Pivot considerations. It is usually much better not to try to do this inside the database. If you think about it. The data itself can be fetch from the database very easily. To do a PIVOT is a kind of GUI/Layout representation for this data. This should be done in the GUI Layer.
    >
    I tried to respond to the thread Billy posted in, so I'll cut and paste my response here:
    Discussion
    Where do we as database developers draw the line between the correct use of SQL or not? Or between rendering on the client and just returning data?
    Now with LISTAGG, PIVOT and UNPIVOT all available to us would these be considered correct uses of SQL?
    Where does this leave the TO_CHAR function? Is this considered rendering?
    I'm fully expecting a fuzzy answer with something along the lines of "do the work where it makes the most sense" from a ease of development and maintainability perspective but I just wanted to ask.
    Hopefully this is a valuable discussion.
    Thanks!

    Let me give a simple example. You can store images in a table as a LOB. You can serve these images to a web browser client via mod_plsql.
    However, the data is static. It requires I/O (and some hefty ones for larger images). What is the biggest performance penalty we have in Oracle? I/O? What is affected by doing I/O to read these images? The buffer cache (which will age out other data in the cache).
    Where else can we store this data? The web server. At what cost to the performance of Oracle? None. Impact on web server? Heck, web servers are designed at their very core to do this!
    So where is the best place to storage static images in this specific case? Not the database, but the web server.
    Now simply extend this concept to the client - where is the best place to render data?
    Should the data be formatted for rendering (e.g. converted into HTML) in the database layer, or should it rather be done in the presentation layer?
    Now I can already hear the argument that the former is exactly what we are doing using APEX. We create dynamic HTML pages on the Oracle server side and then dish that up to the rendering layer to display.
    Two issues that need to be considered. Firstly, this is not done using SQL. This is done using a procedure language called PL/SQL - not using native SQL. PL/SQL in this case is used exactly as Java or PHP or Perl or any other "+app layer+" language would be used. It only happens that PL/SQL resides in the database too. But do not mistake it for what it really is - the application layer.
    The second issue drives home the point that even in 3 tier client server, the application layer is not the best place to do the formatting for the rendering layer. Web 2.0 aka AJAX.. Where the app layer delivers a dynamic rendering engine (as Javascript) to the rendering layer. After which rendering and formatting are done solely inside that rendering layer. And interaction between that and the app layer is requests for new/fresh data to be rendered.
    Why is AJAX becoming so popular? Key issues and concepts like performance, and a rich client interface and so on.
    This all points that the fundamental principle of using the rendering layer to do its thing and using the SQL layer to do its (separate and different) thing, still holds true.
    Yes, we may not always stick to this principle - as we do with doing the rendering (creating HTML) in PL/SQL using APEX for example.. but this is not because the principle is unsound. It is because of technology reasons (different browsers, different behaviour), lack of support for W3C standards (hello IE) and so on.
    It is only recently that these problem areas have been meaningfully addressed.. and why rendering frameworks like extJS is the (rendering layer) future of 3 tier client server.
    If the concept of using SQL to perform rendering and formatting had any substance.. then there would have been a lot of resistance to AJAX for example. The reverse is true.. as we all want to use SQL to do SQL and want the rendering layer to do its thing without us having to code in SQL to specifically support rendering and formatting. It is clunky. It slows down the SQL (every formatting function is a tiny overhead that adds up). It does not bode well for maintenance and changes to the presentation layer. And all those tiny overheads can spell doom for scalability.
    I do not see any gray lines here, or a question of "+opinion+", or "+it depends+". The architecture is clear. The fundamentals are sound.
    The real issue is how we choose to apply these. But (the "+incorrect+") application (of these fundamentals) does not invalidate the fundamentals.

  • Transact-SQL debugger not working in SQL Server 2008: "...debugger does not support SQL Server 2005 or earlier..."

    I have recently installed SQL Server 2008. When I try to execute a query against an Access database, I receive this debugging error:
    "Unable to start Transact-SQL debugger. The Transact-SQL debugger does not support SQL Server 2005 or earlier versions of SQL Server. (SQLEditors)"
    Nor will the query execute; I get a transport-level error 0. Any thoughts?

    Hi Davidmhjr,
    >>Unable to start the Transact-SQL Debugger. The Transact-SQL Debugger does not support SQL Server 2005 or earlier versions of SQL Server. (SQLEditors).
    Have you tried to restart the server once you have installed SQL Server 2008? As Naomi N mentioned please check the version of SQL Server you are using.
    If you tried to connect to SQL Server 2005 from SQL Server 2008 SSMS, you would not be able to debug and get this error, it happens because T-SQL debugger includes both server-side and client-side components. The server-side debugger components are installed
    with each instance of the SQL Server 2008 Database Engine. The client-side components are installed when you install the SQL Server 2008 client-side tools.
    So it works with SQL Server 2008 only so far. Another way is you can triy to use SQL Server 2005 SSMS to connect to SQL Server 2005.
    More information about configuration requirement to run T-SQL debugger as below, please refer:
    There are no configuration requirements to run the Transact-SQL debugger when SQL Server Management Studio is running on the same computer as the instance of the SQL Server Database Engine. However, to run the Transact-SQL debugger when SQL Server Management
    Studio is running on a different computer from the instance of the Database Engine, you must enable program and port exceptions by using the Windows Firewall Control Panel application on both computers.
    On the computer that is running the instance of the Database Engine, in Windows Firewall, specify the following information:
    •Add TCP port 135 to the exceptions list.
    •Add the program sqlservr.exe to the exceptions list. By default, sqlservr.exe is installed in C:\Program Files\Microsoft SQL Server\MSSQL10.InstanceName\MSSQL\Binn, where InstanceName is MSSQLSERVER for the default instance, and the instance name for
    any named instance.
    •If the domain policy requires network communications to be done through IPsec, you must also add UDP port 4500 and UDP port 500 to the exception list.
    On the computer that is running SQL Server Management Studio, in Windows Firewall, specify the following information:
    •Add TCP port 135 to the exceptions list.
    •Add program ssms.exe (SQL Server Management Studio) to the exceptions list. By default, ssms.exe is installed in C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE.
    Hope it is helpful.
    Regards, Amber zhang

  • Set Column width in query (not using SQL*Plus)

    How can I Set Column width in query
    I understand you can set column width using
    column col1 FORMAT A5
    select col1 from table1;But this only works in SQL*Plus
    I want to be able to do this in a regular SQL query window (not in SQL*Plus), how can I do it.....
    I am using a 'SQL window' in PL/SQL Developer IDE
    and when I use this syntax it says:
    ORA-00900: Invalid SQL statement
    Any suggestions are appreciated...
    thanks,
    M.

    Did you try using RPAD or LPAD functions? They fill the unfilled part of a string with character you provide... either on right or left side depending on what function you use.
    e.g.
    SELECT RPAD('Smith', 10, ' ') Name FROM dual;http://www.adp-gmbh.ch/ora/sql/rpad.html
    Edited by: Zaafran Ahmed on Nov 10, 2010 11:50 AM

  • Db link error in PL/SQL but not in SQL

    oracle 10.2.0.4
    solaris 10
    I have a simple procedure (anonymous block) that uses a db link to update a table in another db (on same host)
    The procedure fails with the following error:
    ORA-02019: connection description for remote database not found
    I can insert records using the same db_link using the exact same line pasted from the stored proc (same line that raises the ORA-02019).
    insert into table_x@my_db_link (select * from local_table_y);
    x rows inserted
    I use the same sql*plus session to run both the stored proc and sql command;
    SQL> conn my_user/my_pwd
    connected
    SQL> @my_proc.sql
    ORA-02019: connection description for remote database not found
    SQL> insert into table_x@my_db_link (select * from local_table_y);
    x rows inserted
    QUESTION:
    Why does the db_link fail in the procedure and not the sql command line call?
    P.S.
    I converted the procedure to a store proc and it also fails with the same call.

    Perhaps if the Database link is non-public?There is a bug, #3240720, which applies when the owner of the db link is not the user who's executing the query.
    There are several bugs which demonstrate this sort of behaviour. For instance ORA-2019 can be hurled if the local PL/SQL is running against a remote Dataguard standby database (although I would hope we wouldn't be running an INSERT in that scenario).
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • SQL Server Management 6.5.1.0 and 6.5.4.0 does not discovery SQL 2008 databases on Windows 2003

    SQL Server Management 6.5.1.0 and 6.5.4.0 does not discovery SQL 2008 databases on a custom instance name or when multiple SQL instances are installed on Windows 2003.
    OS Version: Windows 2203 x64 with SP2
    Database Version: 10.3.5869.0
    The instance in this case: I01 is running on port 49168.
    SQL Server Network Configuration | Protocols for I01 | IP Addresses | IPAll | TCP Port = 49168
    The DB Engine class is discovered but not the "Tcp Port" property.
    The database discovery script then fails as it is missing the 8th parameter; The Port.
    Looking at the discovery script DiscoverSQL2008DBEngineDiscovery.vbs i see the following WMI query.
    Set oWMI = GetObject("winmgmts:\\" & computerName & "\root\Microsoft\SqlServer\" & SQL_WMI_NAMESPACE)  
    Set oQuery = oWMI.ExecQuery("SELECT * FROM ServerNetworkProtocolProperty
    Using WMI Explorer if I connect to namespace: root\Microsoft\SqlServer\ComputerManagement10
    and query "SELECT * FROM ServerNetworkProtocolProperty". There are no instances.
    What am I missing or doing wrong?
    Closely related to this article. https://gallery.technet.microsoft.com/Hotfix-Management-Pack-SQL-17cf1118#content.
    Thanks
    Gavin

    Hi,
    I would like to know is there any update about the issue. If the issue is solved, will you please share the resolution here to help others in this forum who encounter similar issue.
    Regards,
    Yan Li
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Help required in writing an sql querry

    Hi guys,
    Could any one hlep me out in writing an sql querry for the below requirement.
    the requirement is: for a perticular ID if we have different names then we need to get it out as multiple else the name itselef. I have given the sample input and the expected output.
    ID Name
    1 A
    1 B
    2 F
    2 F
    3 C
    4 D
    4 E
    Out put should look like
    ID Name
    1 Multiple
    2 F
    3 C
    4 Multiple
    Thanks in advance
    Shylender.
    Edited by: 959345 on Nov 22, 2012 10:13 PM

    May be this:
    WITH t AS
            (SELECT 1 id, 'A' str FROM DUAL
             UNION ALL
             SELECT 1, 'B' FROM DUAL
             UNION ALL
             SELECT 2, 'F' FROM DUAL
             UNION ALL
             SELECT 2, 'F' FROM DUAL
             UNION ALL
             SELECT 3, 'C' FROM DUAL
             UNION ALL
             SELECT 4, 'D' FROM DUAL
             UNION ALL
             SELECT 4, 'E' FROM DUAL),
         t1 AS
            (SELECT id,
                    CASE
                       WHEN COUNT (DISTINCT str) OVER (PARTITION BY id) > 1 THEN
                          'MULTIPLE'
                       ELSE
                          str
                    END
                       str
               FROM t)
      SELECT id, str
        FROM t1
    GROUP BY id, str
    ORDER BY 1;Cheers,
    Manik.

  • Sp2-0575: Use of oracle SQL feature  not in sql 92 entry level.

    Hi,
    While logging to sqlplus I'm getting the following message
    "sp2-0575: Use of oracle SQL feature not in sql 92 entry level."
    and login is successful, but I'm not able to generate next value from the sequence .
    t says no rows selected when i request
    for nextval a
    EX: select mySeq.nextval from dual; (mySeq is sequence)
    Thanx,
    Ravi.

    What has happened is that someone has enabled the Oracle feature called as FIPS flagger.
    This is a feature that Oracle provides to you if you plan to write SQL code that should be portable
    to other RDBMS systems. IF you enable this flagger and use a feature which is not in the SQL standard,
    Oracle will complain that use of this feature will make your application Oracle dependent, and you may not
    be able to run this application against any other RDBMS.
    To disable this for your SQL*Plus session do this:
    SQL> set flagger off
    SQL>
    Once you do this it will allow you to use all SQL commands including Oracle specific extensions.

  • Why would SMO WMI not return SQL 2012 Services in the ManagedComputer.Services collection when the instances are in ServerInstances

    The following code
    var comp = new Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer();
    var bob = comp.Services;
    Only returns the 2008R2 instances on my machine not the sql 2012 instances.
    Oddly the ServerInstances includes all the instances.
    This means I can't get the StartupParameters for the instance.
    I've checked and its definitely using the sql 2012 version of SMO. All services are using the same user account (Network Service)
    Can anyone think why this would be.
    @simon_sabin -
    SQL Know How - SQL Server Consultancy and Real world training - SQLBits - Largest SQL Server Conference in Europe and its free

    2014-09-08T20:23:33.1175952+02:00 *** Test of the default constructor of ManagedComputer
    Name of the ManagedComputer : USER-PC
    - 3 ClientProtocols
    - 0 ServerAliases
    - 3 ServerInstances
    - Instance : EXPRESS_ADV_2014
    - Instance : EXPRESSADV2014
    - Instance : SQLEXPRESS
    - 12 Services
    List of the available services :
    - Service : MSSQL$EXPRESS_ADV_2014
    - DisplayName : SQL Server (EXPRESS_ADV_2014)
    - ErrorControl : Normal
    - PathName : "F:\Install_SQLServerExpress2014\MSSQL12.EXPRESS_ADV_2014\MSSQL\Binn\sqlservr.exe" -sEXPRESS_ADV_2014
    - ProcessId : 1972
    - ServiceState : Running
    - Type : SqlServer
    - StartMode : Auto
    - Service : MSSQL$EXPRESSADV2014
    - DisplayName : SQL Server (EXPRESSADV2014)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSSQL12.EXPRESSADV2014\MSSQL\Binn\sqlservr.exe" -sEXPRESSADV2014
    - ProcessId : 0
    - ServiceState : Stopped
    - Type : SqlServer
    - StartMode : Disabled
    - Service : MSSQL$SQLEXPRESS
    - DisplayName : SQL Server (SQLEXPRESS)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS_ADV\MSSQL\Binn\sqlservr.exe" -sSQLEXPRESS
    - ProcessId : 356
    - ServiceState : Running
    - Type : SqlServer
    - StartMode : Auto
    - Service : MSSQLFDLauncher$EXPRESS_ADV_2014
    - DisplayName : SQL Full-text Filter Daemon Launcher (EXPRESS_ADV_2014)
    - ErrorControl : Normal
    - PathName : "F:\Install_SQLServerExpress2014\MSSQL12.EXPRESS_ADV_2014\MSSQL\Binn\fdlauncher.exe" -s MSSQL12.EXPRESS_ADV_2014
    - ProcessId : 1708
    - ServiceState : Running
    - Type : 9
    - StartMode : Manual
    - Service : MSSQLFDLauncher$EXPRESSADV2014
    - DisplayName : SQL Full-text Filter Daemon Launcher (EXPRESSADV2014)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSSQL12.EXPRESSADV2014\MSSQL\Binn\fdlauncher.exe" -s MSSQL12.EXPRESSADV2014
    - ProcessId : 0
    - ServiceState : Stopped
    - Type : 9
    - StartMode : Manual
    - Service : MSSQLFDLauncher$SQLEXPRESS
    - DisplayName : SQL Full-text Filter Daemon Launcher (SQLEXPRESS)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS_ADV\MSSQL\Binn\fdlauncher.exe" -s MSSQL11.SQLEXPRESS_ADV
    - ProcessId : 3980
    - ServiceState : Running
    - Type : 9
    - StartMode : Manual
    - Service : ReportServer$EXPRESSADV2014
    - DisplayName : SQL Server Reporting Services (EXPRESSADV2014)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSRS12.EXPRESSADV2014\Reporting Services\ReportServer\bin\ReportingServicesService.exe"
    - ProcessId : 0
    - ServiceState : Stopped
    - Type : ReportServer
    - StartMode : Auto
    - Service : ReportServer$SQLEXPRESS
    - DisplayName : SQL Server Reporting Services (SQLEXPRESS)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSRS11.SQLEXPRESS_ADV\Reporting Services\ReportServer\bin\ReportingServicesService.exe"
    - ProcessId : 2516
    - ServiceState : Running
    - Type : ReportServer
    - StartMode : Auto
    - Service : SQLAgent$EXPRESS_ADV_2014
    - DisplayName : SQL Server Agent (EXPRESS_ADV_2014)
    - ErrorControl : Normal
    - PathName : "F:\Install_SQLServerExpress2014\MSSQL12.EXPRESS_ADV_2014\MSSQL\Binn\SQLAGENT.EXE" -i EXPRESS_ADV_2014
    - ProcessId : 0
    - ServiceState : Stopped
    - Type : SqlAgent
    - StartMode : Disabled
    - Service : SQLAgent$EXPRESSADV2014
    - DisplayName : SQL Server Agent (EXPRESSADV2014)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSSQL12.EXPRESSADV2014\MSSQL\Binn\SQLAGENT.EXE" -i EXPRESSADV2014
    - ProcessId : 0
    - ServiceState : Stopped
    - Type : SqlAgent
    - StartMode : Disabled
    - Service : SQLAgent$SQLEXPRESS
    - DisplayName : SQL Server Agent (SQLEXPRESS)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS_ADV\MSSQL\Binn\SQLAGENT.EXE" -i SQLEXPRESS
    - ProcessId : 0
    - ServiceState : Stopped
    - Type : SqlAgent
    - StartMode : Disabled
    - Service : SQLBrowser
    - DisplayName : SQL Server Browser
    - ErrorControl : Normal
    - PathName : "C:\Program Files (x86)\Microsoft SQL Server\90\Shared\sqlbrowser.exe"
    - ProcessId : 2628
    - ServiceState : Running
    - Type : SqlBrowser
    - StartMode : Auto
    Hello Simon ,
    For SMO assemblies : the version is 11 for SQL Server 2012 , and 10 for SQL Server 2008 R2 ( and not 10.5 , so when you have SQL Server 2008 and 2008 R2 , the SMO assemblies for 2008 are replaced by the SMO assemblies for 2008 R2 ). I faced this
    problem when I installed SQL Server 2008 R2 aside a left 2008 install.
    On my current computer , I have only 2012 and 2014 instances and I have no problem.
    To check the version of the assemblies ( Microsoft.Smo.SqlWmiManagement mainly ) in your Visual Studio , click on the name of this assembly and look at the Version : it should be 11.0.0 ( for SQL Server 2012 ).
    Yesterday , I have written a little application to view the instances and services on my computer.
    using System.Collections.Specialized;
    using System.Data;
    using System.Linq;
    using System.Management;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using Microsoft.SqlServer.Management.Common;
    using Microsoft.SqlServer.Management.Dmf;
    using Microsoft.SqlServer.Management.Facets;
    using Microsoft.SqlServer.Management.Sdk.Sfc;
    using Microsoft.SqlServer.Management.Smo;
    using Microsoft.SqlServer.Management.Smo.SqlEnum;
    using Microsoft.SqlServer.Management.Smo.Wmi;
    namespace Test_ManagedComputer_SMO2014_VCS2014
    /// <summary>
    /// Class for fields/properties/methods used in the Main method
    /// </summary>
    class Program
    private static ManagedComputer m_mc = null;
    public static ManagedComputer Mc
    get
    return m_mc;
    private set
    m_mc = value;
    static void Main( string[] args )
    String _s = "";
    if ( !CommonCls.AppInit("en-US" , true ) )
    return;
    _s = "Test of the default constructor of ManagedComputer";
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(true , _s);
    m_mc = new ManagedComputer();
    _s = String.Format("Name of the ManagedComputer : {0}" , m_mc.Name );
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false , _s);
    _s = String.Format(" - {0} ClientProtocols" , CommonCls.Int32ToString( m_mc.ClientProtocols.Count , 5 ));
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false , _s );
    _s = String.Format(" - {0} ServerAliases" , CommonCls.Int32ToString( m_mc.ServerAliases.Count , 5 ) );
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false , _s);
    _s = String.Format( " - {0} ServerInstances" , CommonCls.Int32ToString( m_mc.ServerInstances.Count , 5 ) );
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false,_s);
    foreach ( ServerInstance _serverinstance in Mc.ServerInstances )
    _s = String.Format(" - Instance : {0}" , _serverinstance.Name );
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false,_s);
    _s = String.Format( " - {0} Services" , CommonCls.Int32ToString( m_mc.Services.Count , 5 ) );
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false,_s);
    _s = "List of the available services : ";
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false,_s);
    foreach ( Service _service in Mc.Services )
    _s = " - Service : " + _service.Name;
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false,_s);
    _s = " - DisplayName : " + _service.DisplayName;
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false,_s);
    _s = " - ErrorControl : " + _service.ErrorControl.ToString();
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false,_s);
    _s = " - PathName : " + _service.PathName;
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false,_s);
    _s = " - ProcessId : " + _service.ProcessId.ToString();
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false,_s);
    _s = " - ServiceAccount : " + _service.ServiceAccount;
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false ,_s);
    _s = " - ServiceState : " + _service.ServiceState.ToString();
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false,_s);
    _s = " - Type : " + _service.Type.ToString();
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false,_s);
    _s = " - StartMode : " + _service.StartMode.ToString();
    Console.WriteLine(_s);
    CommonCls.AppWriteLog(false,_s);
    EndOfProgram :
    CommonCls.AppClose();
    I am getting the following results
    2014-09-08T20:23:33.1175952+02:00 *** Test of the default constructor of ManagedComputer
    Name of the ManagedComputer : USER-PC
    - 3 ClientProtocols
    - 0 ServerAliases
    - 3 ServerInstances
    - Instance : EXPRESS_ADV_2014
    - Instance : EXPRESSADV2014
    - Instance : SQLEXPRESS
    - 12 Services
    List of the available services :
    - Service : MSSQL$EXPRESS_ADV_2014
    - DisplayName : SQL Server (EXPRESS_ADV_2014)
    - ErrorControl : Normal
    - PathName : "F:\Install_SQLServerExpress2014\MSSQL12.EXPRESS_ADV_2014\MSSQL\Binn\sqlservr.exe" -sEXPRESS_ADV_2014
    - ProcessId : 1972
    - ServiceState : Running
    - Type : SqlServer
    - StartMode : Auto
    - Service : MSSQL$EXPRESSADV2014
    - DisplayName : SQL Server (EXPRESSADV2014)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSSQL12.EXPRESSADV2014\MSSQL\Binn\sqlservr.exe" -sEXPRESSADV2014
    - ProcessId : 0
    - ServiceState : Stopped
    - Type : SqlServer
    - StartMode : Disabled
    - Service : MSSQL$SQLEXPRESS
    - DisplayName : SQL Server (SQLEXPRESS)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS_ADV\MSSQL\Binn\sqlservr.exe" -sSQLEXPRESS
    - ProcessId : 356
    - ServiceState : Running
    - Type : SqlServer
    - StartMode : Auto
    - Service : MSSQLFDLauncher$EXPRESS_ADV_2014
    - DisplayName : SQL Full-text Filter Daemon Launcher (EXPRESS_ADV_2014)
    - ErrorControl : Normal
    - PathName : "F:\Install_SQLServerExpress2014\MSSQL12.EXPRESS_ADV_2014\MSSQL\Binn\fdlauncher.exe" -s MSSQL12.EXPRESS_ADV_2014
    - ProcessId : 1708
    - ServiceState : Running
    - Type : 9
    - StartMode : Manual
    - Service : MSSQLFDLauncher$EXPRESSADV2014
    - DisplayName : SQL Full-text Filter Daemon Launcher (EXPRESSADV2014)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSSQL12.EXPRESSADV2014\MSSQL\Binn\fdlauncher.exe" -s MSSQL12.EXPRESSADV2014
    - ProcessId : 0
    - ServiceState : Stopped
    - Type : 9
    - StartMode : Manual
    - Service : MSSQLFDLauncher$SQLEXPRESS
    - DisplayName : SQL Full-text Filter Daemon Launcher (SQLEXPRESS)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS_ADV\MSSQL\Binn\fdlauncher.exe" -s MSSQL11.SQLEXPRESS_ADV
    - ProcessId : 3980
    - ServiceState : Running
    - Type : 9
    - StartMode : Manual
    - Service : ReportServer$EXPRESSADV2014
    - DisplayName : SQL Server Reporting Services (EXPRESSADV2014)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSRS12.EXPRESSADV2014\Reporting Services\ReportServer\bin\ReportingServicesService.exe"
    - ProcessId : 0
    - ServiceState : Stopped
    - Type : ReportServer
    - StartMode : Auto
    - Service : ReportServer$SQLEXPRESS
    - DisplayName : SQL Server Reporting Services (SQLEXPRESS)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSRS11.SQLEXPRESS_ADV\Reporting Services\ReportServer\bin\ReportingServicesService.exe"
    - ProcessId : 2516
    - ServiceState : Running
    - Type : ReportServer
    - StartMode : Auto
    - Service : SQLAgent$EXPRESS_ADV_2014
    - DisplayName : SQL Server Agent (EXPRESS_ADV_2014)
    - ErrorControl : Normal
    - PathName : "F:\Install_SQLServerExpress2014\MSSQL12.EXPRESS_ADV_2014\MSSQL\Binn\SQLAGENT.EXE" -i EXPRESS_ADV_2014
    - ProcessId : 0
    - ServiceState : Stopped
    - Type : SqlAgent
    - StartMode : Disabled
    - Service : SQLAgent$EXPRESSADV2014
    - DisplayName : SQL Server Agent (EXPRESSADV2014)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSSQL12.EXPRESSADV2014\MSSQL\Binn\SQLAGENT.EXE" -i EXPRESSADV2014
    - ProcessId : 0
    - ServiceState : Stopped
    - Type : SqlAgent
    - StartMode : Disabled
    - Service : SQLAgent$SQLEXPRESS
    - DisplayName : SQL Server Agent (SQLEXPRESS)
    - ErrorControl : Normal
    - PathName : "C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS_ADV\MSSQL\Binn\SQLAGENT.EXE" -i SQLEXPRESS
    - ProcessId : 0
    - ServiceState : Stopped
    - Type : SqlAgent
    - StartMode : Disabled
    - Service : SQLBrowser
    - DisplayName : SQL Server Browser
    - ErrorControl : Normal
    - PathName : "C:\Program Files (x86)\Microsoft SQL Server\90\Shared\sqlbrowser.exe"
    - ProcessId : 2628
    - ServiceState : Running
    - Type : SqlBrowser
    - StartMode : Auto
    CommonCls.AppWriteLog is only a method which has 2 parameters , the 2nd one is the string to write in a application log , the 1st if true , the current datetime is written before the content of the 1st parameter. It is useful to simulate a hardcopy of the screen
    , especially when the application is a console one.
    I have not tested to write the startup parameters but it was working in a previous application
    As you can see , I have 3 instances , 1 SQL Server 2012 and 2 SQL Server 2014 ( but one is "ill" it's why the startup of the SQL Server service is disabled , it will be repaired when I will reinstall W7 or install W8 )
    I don't see any reason why you are not seen the 2012 instances except if the version of your assembly is 10 instead 11 ( a little tip :when you are adding a reference , in the box after a browse , you are sorting the names of the
    assemblies in the selection box , as the assemblies 2008/2008 R2 are appearing before the assemblies 2012 , it' minimizing the risk of confusion of assemblies and try to increase the visibility of the full path by double-clicking the title of the Path
    column , if you don't do that , you should not see the version number included in the path name ).
    Don't hesitate to post again for more help or explanations.
    Have a nice day
    Patrick
    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

  • Configuration note  of SQL SERVER 2005

    Hello,
    Is there a SAP configuration note for SQL 2005 like note 327494 for SQL 2000 ?
    Or does someone know if there should be special configuration for SQL SERVER 2005 ?
    Pelase advice,
    Dimitry

    Hello
    Please review 879941 Configuration Parameters for SQL Server 2005
    thanks
    N.P.C

  • Suppress Powershell Warning in agent job "WARNING: Could not obtain SQL Server Service information"

    Hi
    I get this warning running through powershell_ise but through sql agent it just errors out.
    The code does everything it is supposed to and I tried everything to completely resolve the warning to no avail.
    How do I supress it so sql agent wont error out running powershell code?
    Thanks!
    WARNING: Could not obtain SQL Server Service information. An attempt to connect to WMI on 'server_name' failed with the following error: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
    Warning only present when it connects to remote servers, it doesn't produce it for local server. And it does get all info from the remote servers.
    Paula

    Hi paulata,
    According to your description, when you run powershell scripts about  the remote machine
     in SQL Server Agent job, the warning error will occur. “The common error message is Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).” This suggests that your credentials aren't sufficient for accessing the
    remote system. If you have an account that has sufficient permissions for the query, there's a simple workaround for this problem in the form of PowerShell's Get-Credential command and the script's Credential parameter. I recommend you check if your account
    has permission on remote machine and it can execute the powershell scripts.
    In addition, if you want to run query statement on the remote machine , I recommend you create Linked Server, then do some related operations. There is a similar issue about access denied, you can review the following article.
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/157f536d-6716-4547-bdb4-9e3c8451cb95/sql-agent-service-account-permissions-sql-server-2008?forum=sqlgetstarted
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Could not start SQL services (Plz help me)

    I logged in windows with an administrator account, but I could not start sql services. Here is the newest log file, please help me to fix it. Thank in advanced.
    2014-10-02 16:17:49.06 Server      Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86) 
    Oct 14 2005 00:33:37 
    Copyright (c) 1988-2005 Microsoft Corporation
    Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 3)
    2014-10-02 16:17:49.06 Server      (c) 2005 Microsoft Corporation.
    2014-10-02 16:17:49.06 Server      All rights reserved.
    2014-10-02 16:17:49.06 Server      Server process ID is 3888.
    2014-10-02 16:17:49.06 Server      Logging SQL Server messages in file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'.
    2014-10-02 16:17:49.06 Server      This instance of SQL Server last reported using a process ID of 1104 at 10/2/2014 4:07:13 PM (local) 10/2/2014 9:07:13 AM (UTC). This is an informational message only; no user action is required.
    2014-10-02 16:17:49.06 Server      Registry startup parameters:
    2014-10-02 16:17:49.06 Server      
    -d C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf
    2014-10-02 16:17:49.06 Server      
    -e C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG
    2014-10-02 16:17:49.06 Server      
    -l C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\mastlog.ldf
    2014-10-02 16:17:49.07 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
    2014-10-02 16:17:49.07 Server      Detected 2 CPUs. This is an informational message; no user action is required.
    2014-10-02 16:17:49.71 Server      Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
    --The Anh--

    Hello,
    Can you tell us the status of the issue ? If you have found answer please post here so that it can help other members when needed. If You found answer in this thread please mark answer to the post and close the thread
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Articles

  • Looking for gaps (SQL, not PL/SQL)

    Hi,
    This is a SQL (not PL/SQL) question.
    Let's say I have the following table:
    COLtype          COLnumber
    AA               1
    AA               2
    AA               4
    AA               5
    BB               1
    BB               2
    BB               3
    BB               5
    CC               1
    CC               5
    How do I find all gaps? I expect a result:
    COLtype          COLnumber
    AA               3
    BB               4
    CC               2
    CC               3
    CC               4
    I tried to use query:
    SELECT COLnumber + 1, COLtype FROM table a1
    WHERE NOT EXISTS (
    SELECT NULL FROM table a2
         WHERE
    a1.COLtype = a2.COLtype
    and (a2.COLnumber = a1.COLnumber + 1)
    but I received as result:
    COLtype          COLnumber
    AA               3
    AA               6
    BB               4
    BB               6
    CC               2
    CC               3
    CC               4
    CC               6
    Any other solutions, ideas?
    Thanks in advance!
    Gaspar
    Edited by: 985540 on 2013-02-01 02:59

    First let define gaps. If we have:
    COLtype COLnumber
    AA      3
    AA      4Are:
    COLtype COLnumber
    AA      1
    AA      2missing? If so is there an assumption COLnumber always starts with 1 or we just looking for gaps between existing numbers? For now I'll assume we are looking for gaps between existing numbers. Then:
    with t as (
               select  coltype,
                       colnumber,
                       lag(colnumber,1,colnumber - 1)
                         over(
                              partition by coltype
                              order by colnumber
                             ) prev_colnumber
                 from  tbl
    select  coltype,
            colnumber - column_value colnumber
      from  t,
            table(
                  cast(
                       multiset(
                                select  level
                                  from  dual
                                  connect by level < colnumber - prev_colnumber
                       as sys.OdciNumberList
      where colnumber - prev_colnumber > 1
      order by coltype,
               colnumber
    CO  COLNUMBER
    AA          3
    BB          4
    CC          2
    CC          3
    CC          4
    SQL> explain plan for
      2  with t as (
      3             select  coltype,
      4                     colnumber,
      5                     lag(colnumber,1,colnumber - 1)
      6                       over(
      7                            partition by coltype
      8                            order by colnumber
      9                           ) prev_colnumber
    10               from  tbl
    11            )
    12  select  coltype,
    13          colnumber - column_value colnumber
    14    from  t,
    15          table(
    16                cast(
    17                     multiset(
    18                              select  level
    19                                from  dual
    20                                connect by level < colnumber - prev_colnumber
    21                             )
    22                     as sys.OdciNumberList
    23                    )
    24               )
    25    where colnumber - prev_colnumber > 1
    26    order by coltype,
    27             colnumber
    28  /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 1739894384
    | Id  | Operation                            | Name | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                     |      | 81680 |  2552K|       |   991   (1)| 00:00:12 |
    |   1 |  SORT ORDER BY                       |      | 81680 |  2552K|  3216K|   991   (1)| 00:00:12 |
    |   2 |   NESTED LOOPS                       |      | 81680 |  2552K|       |   277   (1)| 00:00:04 |
    |*  3 |    VIEW                              |      |    10 |   300 |       |     4  (25)| 00:00:01 |
    |   4 |     WINDOW SORT                      |      |    10 |   170 |       |     4  (25)| 00:00:01 |
    |   5 |      TABLE ACCESS FULL               | TBL  |    10 |   170 |       |     3   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |   6 |    COLLECTION ITERATOR SUBQUERY FETCH|      |  8168 | 16336 |       |    27   (0)| 00:00:01 |
    |*  7 |     CONNECT BY WITHOUT FILTERING     |      |       |       |       |            |          |
    |   8 |      FAST DUAL                       |      |     1 |       |       |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - filter("COLNUMBER"-"PREV_COLNUMBER">1)
       7 - filter(LEVEL<:B1-:B2)
    PLAN_TABLE_OUTPUT
    Note
       - dynamic sampling used for this statement (level=2)
    25 rows selected.
    SQL> SY.

Maybe you are looking for

  • Email notification to Manager on routine change request

    I am trying to set up a multi review activity template for routine change request. The first Review Activity should notify the creator of the Change Requests Manager so the Manager can review. In the Review Activity, there is a check box for "Line Ma

  • What's New in Adobe InDesign CC | Creative Cloud for Design | Adobe TV

    Terry White, Adobe worldwide evangelist, shows you the exciting new features in InDesign CC, including the new dark UI, an improved New Document dialog box, and font menu enhancements that make searching for fonts easier than ever and let you see liv

  • IPhone doesn't recognize some keys

    I bought a 3G (not 3GS) iPhone a couple of weeks ago. After a few days, it stopped recognizing the O and 9 keys on vertical (portrait) keyboards. That problem went away after a couple of days. Now, about a week later, the probelm has returned. Apple

  • Auto sync with shuffle?!?!

    Hi I just got a new iPod shuffle because i was using a friends iPod nano and i loved the way i could sync with podcasts, i could automatically put the most recent i have not listened to. However i cant seem to sync with the iPod shuffle in the same w

  • Orgainisational steps break down financial statment.

    Dear Friends, "In the financial statment adjustment breaks the receivables, payables and taxes down in the additional account assignments "Business area" and "Prfit Center" which are store in GL account." I m in the mid of Organizational Steps Lesson