SQL 2012 database behaves differently with a unique index and ignore_dup_key = on when inserting data. It works on SQL 2008 db

If you have a table with a unique index and ignore_dup_key = on and you INSERT rows into that table with an ORDER BY clause (because you want to control which of the duplicate
key rows gets inserted),  the wrong row gets inserted in SQL2012.  It works correctly in SQL 2008.
We have recently migrated  a database from SQL 2008 to SQL 2012.  We do have few other dbs which are in compatability mode 100.  The above operation works fine
in SQL 2008 dbs but not SQL 2012.
I've even tried applying the latest patch for SQL 2012 SP2 with CU2. Still the problem exists.  I'm going to call MS support, but want to know if anyone has come across this problem ?

The MS documentation doesn't guarantee that the first row of the duplicates will always be inserted and the next duplicate row(s) get(s) ignored. Where did you find it in the MS documentation? I think you were just lucky that it was always inserting the
first row in SQL 2008 (and ignoring the rest of the duplicates) - I don't think this is guaranteed
Satish Kartan http://www.sqlfood.com/

Similar Messages

  • What index is suitable for a table with no unique columns and no primary key

    alpha
    beta 
    gamma
    col1
    col2
    col3
    100
    1
    -1
    a
    b
    c
    100
    1
    -2
    d
    e
    f
    101
    1
    -2
    t
    t
    y
    102
    2
    1
    j
    k
    l
    Sample data above  and below is the dataype for each one of them
    alpha datatype- string 
    beta datatype-integer
    gamma datatype-integer
    col1,col2,col3 are all string datatypes. 
    Note:columns are not unique and we would be using alpha,beta,gamma to uniquely identify a record .Now as you see my sample data this is in a table which doesnt have index .I would like to have a index created covering these columns (alpha,beta,gamma) .I
    beleive that creating clustered index having covering columns will be better.
    What would you recommend the index type should be here in this case.Say data volume is 1 milion records and we always use the alpha,beta,gamma columns when we filiter or query records 
    what index is suitable for a table with no unique columns and primary key?
    col1
    col2
    col3
    Mudassar

    Many thanks for your explanation .
    When I tried querying using the below query on my heap table the sql server suggested to create NON CLUSTERED INDEX INCLUDING columns    ,[beta],[gamma] ,[col1] 
     ,[col2]     ,[col3]
    SELECT [alpha]
          ,[beta]
          ,[gamma]
          ,[col1]
          ,[col2]
          ,[col3]
      FROM [TEST].[dbo].[Test]
    where   [alpha]='10100'
    My question is why it didn't suggest Clustered INDEX and chose NON clustered index ?
    Mudassar

  • ORA-01502 error in case of unusable unique index and bulk dml

    Hi, all.
    The db is 11.2.0.3 on a linux machine.
    I made a unique index unusable, and issued a dml on the table.
    Howerver, oracle gave me ORA-01502 error.
    In order to avoid ORA-01502 error, do I have to drop the unique index ,and do bulk dml, and recreate the index?
    Or Is there any other solution without re-creating the unique index?
    create table hoho.abcde as
    select level col1 from dual connect by level <=1000
    10:09:55 HOHO@PD1MGD>create unique index hoho.abcde_dx1 on hoho.abcde (col1);
    Index created.
    10:10:23 HOHO@PD1MGD>alter index hoho.abcde_dx1 unusable;
    Index altered.
    Elapsed: 00:00:00.03
    10:11:27 HOHO@PD1MGD>delete from hoho.abcde where rownum < 11;
    delete from hoho.abcde where rownum < 11
    ERROR at line 1:
    ORA-01502: index 'HOHO.ABCDE_DX1' or partition of such index is in unusable stateThanks in advance.
    Best Regards.

    Hi. all.
    The following is from "http://docs.oracle.com/cd/E14072_01/server.112/e10595/indexes002.htm#CIHJIDJG".
    Is there anyone who can show me a tip to avoid the following without dropping and re-creating an unique index?
    •DML statements terminate with an error if there are any unusable indexes that are used to enforce the UNIQUE constraint.
    Unusable indexes
    An unusable index is ignored by the optimizer and is not maintained by DML. One reason to make an index unusable is if you want to improve the performance of bulk loads. (Bulk loads go more quickly if the database does not need to maintain indexes when inserting rows.) Instead of dropping the index and later recreating it, which requires you to recall the exact parameters of the CREATE INDEX statement, you can make the index unusable, and then just rebuild it. You can create an index in the unusable state, or you can mark an existing index or index partition unusable. The database may mark an index unusable under certain circumstances, such as when there is a failure while building the index. When one partition of a partitioned index is marked unusable, the other partitions of the index remain valid.
    An unusable index or index partition must be rebuilt, or dropped and re-created, before it can be used. Truncating a table makes an unusable index valid.
    Beginning with Oracle Database 11g Release 2, when you make an existing index unusable, its index segment is dropped.
    The functionality of unusable indexes depends on the setting of the SKIP_UNUSABLE_INDEXES initialization parameter.
    When SKIP_UNUSABLE_INDEXES is TRUE (the default), then:
    •DML statements against the table proceed, but unusable indexes are not maintained.
    •DML statements terminate with an error if there are any unusable indexes that are used to enforce the UNIQUE constraint.
    •For non-partitioned indexes, the optimizer does not consider any unusable indexes when creating an access plan for SELECT statements. The only exception is when an index is explicitly specified with the INDEX() hint.
    •For a partitioned index where one or more of the partitions are unusable, the optimizer does not consider the index if it cannot determine at query compilation time if any of the index partitions can be pruned. This is true for both partitioned and non-partitioned tables. The only exception is when an index is explicitly specified with the INDEX() hint.
    When SKIP_UNUSABLE_INDEXES is FALSE, then:
    •If any unusable indexes or index partitions are present, any DML statements that would cause those indexes or index partitions to be updated are terminated with an error.
    •For SELECT statements, if an unusable index or unusable index partition is present but the optimizer does not choose to use it for the access plan, the statement proceeds. However, if the optimizer does choose to use the unusable index or unusable index partition, the statement terminates with an error.Thanks in advance.
    Best Regards.

  • Communication problem with Adobe 9.0 and HP Printer when I scan

    I'm having a problem getting a .pdf file to come up when I scan from a HP 5610 All-in-one printer. Have uninstalled and reinstalled HP software three times but when I scan and want a pdf file it won't communicate with Adobe 9.0 reader for some reason. Is there a setting in Adobe reader that's a problem?
    Thanks.

    Thanks...found out that an HP5610xi All-in-One will not completely communicate with Adobe 9.0   Had to go to Adobe 6.0
    Date: Thu, 17 Dec 2009 03:19:49 -0700
    From: [email protected]
    To: [email protected]
    Subject: Communication problem with Adobe 9.0 and HP Printer when I scan
    May be that the HP software doesn't support Adobe Reader 9.
    >

  • My gen 3 iPod Touch seems to have duplicated all my music since updating to IOS 5 so that it now only holds half as much. What can I do about it? I'm using the same iTunes library with OS 10.6 and all software up to date.

    My gen 3 iPod Touch seems to have duplicated all my music since updating to IOS 5 so that it now only holds half as much. What can I do about it? I'm using the same iTunes library with OS 10.6 and all software up to date.

    Is the camera damaged? Could be a hardware problem.
    Try:
    Close the Camera app in the multitasking bar, then try again.
    Restart/Reset/Restore your iPod. In that order.

  • Hello. I have a problem with OEL 6.5 and ocfs2. When I mount ocfs2 with mount -a command all ocfs2 partitions mount and work, but when I reboot no ocfs2 partitions auto mount. No error messages in log. I use DAS FC and iSCSI FC.

    Hello.
    I have a problem with OEL 6.5 and ocfs2.
    When I mount ocfs2 with mount -a command all ocfs2 partitions mount and work, but when I reboot no ocfs2 partitions auto mount. No error messages in log. I use DAS FC and iSCSI FC.
    fstab:
    UUID=32130a0b-2e15-4067-9e65-62b7b3e53c72 /some/4 ocfs2 _netdev,defaults 0 0
    #UUID=af522894-c51e-45d6-bce8-c0206322d7ab /some/9 ocfs2 _netdev,defaults 0 0
    UUID=1126b3d2-09aa-4be0-8826-0b2a590ab995 /some/3 ocfs2 _netdev,defaults 0 0
    #UUID=9ea9113d-edcf-47ca-9c64-c0d4e18149c1 /some/8 ocfs2 _netdev,defaults 0 0
    UUID=a368f830-0808-4832-b294-d2d1bf909813 /some/5 ocfs2 _netdev,defaults 0 0
    UUID=ee816860-5a95-493c-8559-9d528e557a6d /some/6 ocfs2 _netdev,defaults 0 0
    UUID=3f87634f-7dbf-46ba-a84c-e8606b40acfe /some/7 ocfs2 _netdev,defaults 0 0
    UUID=5def16d7-1f58-4691-9d46-f3fa72b74890 /some/1 ocfs2 _netdev,defaults 0 0
    UUID=0e682b5a-8d75-40d1-8983-fa39dd5a0e54 /some/2 ocfs2 _netdev,defaults 0 0

    What is the output of:
    # chkconfig --list o2cb
    # chkconfig --list ocfs2
    # cat /etc/ocfs2/cluster.conf

  • My ipod is cracked and it chipped away a little more last night and that's when my wifi stopped working. My wifi works on every other device in my house except for my ipod. Is there something wrong with my ipod?

    My ipod is cracked and it chipped away a little more last night and that's when my wifi stopped working. My wifi works on every other device in my house except for my ipod. Is there something wrong with my ipod?

    Does the iOS device connect to other networks?
    Does the iOS device see the network?
    Any error messages?
    Try right next to the router
    Do other devices now connect?
    Did the iOS device connect before?
    Try the following to rule out a software problem:                 
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Power off and then back on your router
    .- Reset network settings: Settings>General>Reset>Reset Network Settings
    - iOS: Troubleshooting Wi-Fi networks and connections
    - Wi-Fi: Unable to connect to an 802.11n Wi-Fi network       
    - iOS: Recommended settings for Wi-Fi routers and access points
    - Restore from backup. See:
    iOS: How to back up
    - Restore to factory settings/new iOS device.
    If still problem and it does not connect to any networks make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar
    Could it be this?
    iOS: Wi-Fi or Bluetooth settings grayed out or dim
    One user reported that placing the iPod in the freezer fixed the problem. A trick that works frequently with iPhones:
    Settings > AirPlane Mode ON, Do Not Disturb ON
    Power down and wait 5-10 minutes
    Power up
    Settings > AirPlane Mode OFF, Do Not Disturb OFF
    If not successful, an appointment at the Genius Bar of an Apple store is usually in order.
    Apple Retail Store - Genius Bar

  • How do I search for lines with a particular pattern and delete them when a match occurs

    How do I search for lines with a particular patter and delete them when a match occurs? For example delete lines containing SUB_NAME = "?" where ? is any string. 

    How do I search for lines with a particular patter and delete them when a match occurs? For example delete lines containing SUB_NAME = "?" where ? is any string. 
    Lines in what? And what language are you using to develop with?
    Are the lines in a text file? A RichTextBox? A TextBox? Some other control? A List(Of String)?
    Is there some expectation by you that by providing what you wrote in your question post that the knowledge in your mind about what you are thinking about will mysteriously emanate to anybody reading your post so all of the sudden your knowledge will
    become their knowledge and they will be able to provide you with an answer as they will suddenly understand what you are trying to do? Because that's probably impossible. Most people try providing enough information in a question so anybody, even stupid people
    like me, can understand what they want. Maybe you should try that. As well as selecting an appropriate forum for your question in the future. Usually a question like this is related to programming in a particular language therefore a language forum may be
    a good choice. Or not.
    La vida loca

  • I have MacBookpro with OSX 10.9, and my Tata Photon plus  is not working on it. When I try to connect, Its not connecting.. Please Help

    I have a MacBookPro with OSX 10.9, and my Tata Photon plus  is not working on it. When I try to connect, Its not connecting.. Please Help
    <Email Edited by Host>

    Current Firefox versions require a Mac with an Intel processor and OS X 10.6 (Firefox 16 runs on Intel Mac OS X 10.5).
    *http://www.mozilla.org/firefox/25.0/system-requirements/
    For an unofficial Firefox 17.0.10 ESR compatible version that runs on a PowerPC Mac with OS X 10.4.11 or OS X 10.5.8 you can look at TenFourFox.
    *http://www.floodgap.com/software/tenfourfox/
    *http://www.macupdate.com/app/mac/37761/tenfourfox
    *http://code.google.com/p/tenfourfox/wiki/ReleaseNotes1710
    See also:
    *http://code.google.com/p/tenfourfox/wiki/PluginsNoLongerSupported
    *http://code.google.com/p/tenfourfox/wiki/QuickTimeEnabler
    *http://code.google.com/p/tenfourfox/wiki/AAATheFAQ

  • Trouble with creating Spatial Indexes and  "user_sdo_geom_metadata"

    G'day All,
    I've encountered a weird issue while playing around with SDO_GEOMETRY objects under Oracle Apex v3.0.1 on Oracle XE running on Windows Vista.
    The issue started when I attempted to create the spatial index :
    create index geotag_sdx on geotag(location)
    indextype is mdsys.spatial_index;
    and I got the following error:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13203: failed to read USER_SDO_GEOM_METADATA view
    ORA-13203: failed to read USER_SDO_GEOM_METADATA view
    I scratched my head for a sec and thought WTF ? my metadata insert worked... well I was sure it did. However when I ran a select from "user_sdo_geom_metadata" there was no rows, so I tried again and I got an error "name is already used by an existing object", again I thought WTF ?
    After getting the source for the "updatable" view "MDSYS.user_sdo_geom_metadata" I could see that the view was filter by CURRENT_SCHEMA:
    SELECT SDO_TABLE_NAME TABLE_NAME, SDO_COLUMN_NAME COLUMN_NAME, SDO_DIMINFO DIMINFO, SDO_SRID SRID
    FROM SDO_GEOM_METADATA_TABLE
    WHERE sdo_owner = sys_context('userenv', 'CURRENT_SCHEMA')
    I ran SELECT sys_context('userenv', 'CURRENT_SCHEMA') FROM DUAL and it correctly returned the SCHMEA name.
    So from sqlplus and logged in a sys/sysdba I ran a select statement from MDSYS.SDO_GEOM_METADATA_TABLE and i saw the problem, the record was inserted with a SDO_OWNER value of "ANONYMOUS".
    When I logged as the SCHEMA via sqlplus and ran the metadata insert statement it worked fine an d the index could be created.
    Has anyone ran into this issue and how did you fix it as I'm concerned or know what I might be doing wrong ?
    Any help would be most appreciated ?
    Regards
    Mark

    Hi Marks,
    Had a quick look at the stored procedure I'm using and there it is. We don't insert into user_sdo_geom_metadatas but in mdsys.sdo_geom_metadata_table and specify the owner ourselves. Of course, you need a direct grant on mdsys.sdo_geom_metadata_table to be able to do this from a stored procedure.
    Seems we had the problem you are facing even without Apex. Our application has a special admin user that has execute privs on certain packages. But when running the spatial index creation procedure we ran into this "owner" problem.
    Here they use all_sdo_geom_metadata:
    Re: Metadata Error
    Message was edited by:
    renewestenberg

  • I just bought a new laptop because my old one died.  is there any way to sync my phone with the new machine and not lose all my data?

    i just bought a new laptop because my old one died.  is there any way to sync my phone with the new machine and not lose all my data?

    Copy everything from your backup copy of your old computer to your new one.
    Then sync.

  • I've just moved from PC to Mac, with my PC i and using Vmware Player I used to work on 2 Virtual M/C both on 2 external drives, one Windows Server 2000 as operating system and the sec. WindowsXP, is their a way to open these m/c on my mac

    I've just moved from PC to Mac, with my PC i and using Vmware Player I used to work on 2 Virtual M/C both on 2 external drives, one Windows Server 2000 as operating system and the sec. WindowsXP, is their a way to open these m/c on my mac

    I am so glad to hear about your success. As you are new to the Mac environment, I will be glad to help you more.
    You said: "I can't change the setup yet but i have access". I don't understand what you mean about changing the setup! Please let me know more about that.
    I also recommend to use Boot Camp, which allows you to install windows on a partition of your internal hard drive. This has many benefits. First, you can restart your computer and start up in windows. This makes your Mac device a complete windows machine and you gain the most from your hardware when working in Windows. Second, if a problem occures to your Mac OS X, you can restart your machine in Windows and prevent your data from getting lost. Third, you can import the Windows installed on the boot camp partition in to the Mac OS X using VMWare Fusion and work with it as a virtual machine. In this situation, VMWare enables you to work directly with your Windows in the boot camp partition. So it does not create a file package for the virtual machine in OS X.
    Regarding the data safety and reliablity, I strongly recommend using Time Machine. You can also set it up to back up your virtual machines or not. This is possible to set up in the Virtual Machine Preferences Page in VMWare Fusion, or in the Time Machine preferences page in the System Preferences app of OS X.
    Please don't hesitate to ask any other question. I will be glad to help you.

  • MBST behaves Differently with MIGO Cancellation

    Hi,
    I have configured some customised movement types to have their reversed movement types as "qty can be entered...". That is, the quantity can be changed when performing cancellation of material document.
    It works well with the old transaction MBST and MB1A (cancel with reference to material document). However, when I try it with MIGO with Cancellation option, it does not work. The quantity field is grey out, not changable. Anyone any idea why is this so? Thanks.
    Regards,
    Norman

    Hi Norman,
    As an option, you can go into the MIGO transaction, use same selections as you would to create the goods receipt document (ex. Goods Receipt, Purchase Order) but in the movement type field, select your reversal movement type.  Quantity field is open for change.  From what I'm seeing (and from what you stated) the Cancellation option in MIGO assumes the full quantity of the material document is being reversed.
    Regards,
    Dawn

  • UNIQUE INDEX and PRIMARY KEYS

    Hi Friends,
    I am confused about primary keys.
    What is the purpose of this key again? I know it is used for unique constraints.
    Supposing I have a table with two (2) columns which are each indexed as unique.
    Then they can me both candidate at primary key right?
    So why do I need a primary key again? when I have 2 columns which are uniquely index?
    Thanks a lot

    A UNIQUE index creates a constraint such that all values in the index must be distinct. An error occurs if you try to add a new row with a key value that matches an existing row. This constraint does not apply to NULL values except for the BDB storage engine. For other engines, a UNIQUE index allows multiple NULL values for columns that can contain NULL
    The differences between the two are:
    1. Column(s) that make the Primary Key of a table cannot be NULL since by definition; the Primary Key cannot be NULL since it helps uniquely identify the record in the table. The column(s) that make up the unique index can be nullable. A note worth mentioning over here is that different RDBMS treat this differently –> while SQL Server and DB2 do not allow more than one NULL value in a unique index column, Oracle allows multiple NULL values. That is one of the things to look out for when designing/developing/porting applications across RDBMS.
    2. There can be only one Primary Key defined on the table where as you can have many unique indexes defined on the table (if needed).
    3. Also, in the case of SQL Server, if you go with the default options then a Primary Key is created as a clustered index while the unique index (constraint) is created as a non-clustered index. This is just the default behavior though and can be changed at creation time, if needed.
    So, if the unique index is defined on not null column(s), then it is essentially the same as the Primary Key and can be treated as an alternate key meaning it can also serve the purpose of identifying a record uniquely in the table.

  • First Try with JE BDB - Indexes and Inheritance troubles... (FIXED)

    Hi Mark,
    Mark wrote:
    Hi, I'm a newbie here trying some stuff on JE BDB. And now I'm having
    I am happy to help you with this, but I'll have to ask you to re-post this question to the BDB JE forum, which is...
    Sorry for the mistake. I know now that here is the place to post my doubts.
    I'm really interested in JE BDB product. I think it is fantastic!
    Regarding my first post about "Indexes and Inheritance" on JE BDB, I found out the fix for that and actually, it wasn't about "Indexes and Inheritance" but "*Inheritance and Sequence*" because I have my "@Persistent public abstract class AbstractEntity" with a "@PrimaryKey(sequence = "ID_SEQ") private Long id" property.
    This class is extended by all my business classes (@Entity Employee and @Entity Department) so that my business classes have their PrimaryKey autoincremented by the sequence.
    But, all my business classes have the same Sequence Name: "ID_SEQ" then, when I start running my JE BDB at first time, I start saving 3 new Department objects and the sequence for these department objects star with "#1" and finishes with #3.
    Then I continue saving Employee objects (here was the problem) I thought that my next Sequence number could be #4 but actually it was #101 so when I tried to save my very first Employee, I set the property "managerId=null" since this employee is the Manager, then, when I tried to save my second Employee who is working under the first one (the manager employee), I got the following exception message:
    TryingJEBDBApp DatabaseExcaption: com.sleepycat.je.ForeignConstraintException: (JE 4.0.71) Secondary persist#EntityStoreName#com.dmp.gamblit.persistence.BDB.store.eployee.Employee#*managerId*
    foreign key not allowed: it is not present in the foreign database
    persist#EntityStoreName#com.dmp.gamblit.persistence.BDB.store.eployee.Employee
    The solution:
    I fixed it modifying the managerId value from "4" to "101" and it works now!
    At this moment I'm trying to understand the Sequence mechanism and refining concerns about Cursors manipulation...
    Have you any good material about these topics, perhaps a link where I can find more detailed information on these?
    Thanks in advance Mark, thanks for your attention on this and I will post more doubts in the future for sure ;0)
    Regards,
    Diego

    Hi Diego,
    I fixed it modifying the managerId value from "4" to "101" and it works now!I'm glad you found the problem. It is usually best to get the assigned ID from the entity object after you call put(), and then use that value to fill in related fields in other entities. The primary key field (assigned from the sequence) is set by the put() method.
    At this moment I'm trying to understand the Sequence mechanism and refining concerns about Cursors manipulation...Have you any good material about these topics, perhaps a link where I can find more detailed information on these? >
    To find documentation, start at the first message in the forum, the Welcome message:
    http://forums.oracle.com/forums/ann.jspa?annID=250
    This refers to the main JE doc page, the JE FAQ and a white paper on DPL queries. The FAQ has a section on the DPL, which refers to the javadoc. The DPL javadoc has lots of info on using cursors along with indexes (see EntityIndex, PrimaryIndex, SecondaryIndex). The white paper will be useful to you if you're accustomed to using SQL.
    I don't know of any doc on sequences other than the javadoc:
    http://www.oracle.com/technology/documentation/berkeley-db/je/java/com/sleepycat/persist/model/PrimaryKey.html#sequence()
    This doc will point you to info on configuring the sequence, if that's what you're interested in.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • Java.nio select() method return 0 in my client application

    Hello, I'm developing a simple chat application who echo messages But my client application loop because the select() method return 0 This is my code // SERVER package test; import java.io.IOException; import java.net.InetSocketAddress; import java.n

  • Video podcasts not working

    Is anyone having problems with video podcasts? For instance, I have the ABC news video podcast and I can hear it but the video is not working.

  • How to declare class variable with generic parameters?

    I've got a class that declares a type parameter T. I know how to declare a static method, but this doesn't work for a static variable: public class Test< T >     * Map of String to instances of T.     * error: '(' expected (pointing to =)     * <iden

  • Multiple audit records per one report refresh

    We use BO XI R3 on Windows with CMS on DB2. I need to create audit reports on BO report usage with following data: username, timestamp, duration, report name for DeskI and WebI reports. I use auditing on DesktopIntelligenceCacheServer and WebIntellig

  • Mouse acting all crazy in 10.3.9

    My mouse has been acting really funny in 10.3.9 I have pplugged it into my laptop and had no problems with it so i am thinking it is on my G4. It bounces all over the place, I have no control of it. Often it freezes and I mess with the connection and