Display only one row for distinct columns and with multiple rows their valu

Hi,
I have a table having some similar rows for some columns and multiple different rows for some other columns
i.e
o_mobile_no o_doc_date o_status d_mobile_no d_doc_date d_status
9825000111 01-jan-06 'a' 980515464 01-feb-06 c
9825000111 01-jan-06 'a' 991543154 02-feb-06 d
9825000111 01-jan-06 'a' 154845545 10-mar-06 a
What i want is to display only one row for above distinct row along with multiple non distinct colums
ie
o_mobile_no o_doc_date o_status d_mobile_no d_doc_date d_status
9825000111 01-jan-06 'a' 980515464 01-feb-06 c
991543154 02-feb-06 d
154845545 10-mar-06 a
regards,
Kumar

Re: SQL Help

Similar Messages

  • Hi, I have apple account/password on laptop but can't use the same ID etc on new Ipad.  On my account it says ID is only for 1 system.  I really want only one ID for both Ipad and laptop. Thanks

    Hi,
    I have apple account/password on laptop but can't use the same ID etc on new Ipad.  On my account it says ID is only for 1 system.  I really want only one ID for both Ipad and laptop.
    Thanks

    It seems that you have used the AppleIDs to "Purchase" your devices, which marries the two for all time and eternity.
    For info - Using your Apple ID for Apple services
    For Account security issues - Apple ID: Contacting Apple for help with Apple ID account security
    regards
    CCC

  • Display only one variable in the header and not column in WAD

    Hi All,
    my requirement is to be able to display only one variable in the report output header and hide the others. I am able to display all by using the INFO FIELD ITEM and saying variable display ON - but the requirement is very specific for only one variable display.
    how can i achieve this ?
    Thanks,
    Shweta

    Hi,
    You can insert a text item and Turn off the others or Hide these from Filter pane I have done that and then use that query for your WAD.
    Steps:
    1. Uncheck all the variables from your Design item in Analyzer.
    2. Insert a New Text Item and check the Variable you want to display.
    3. Go back and run the Query.
    Even you can change the position in the Query and Save as a workbook.Let me know ,if this works.
    ~AK

  • Multi Language- Picklist fields are displayed only one language for Reports

    Hi!
    I am working on Siebel On Demand with Multi Language (English and Spanish) and it works well for web interface, the automatic translation for picklist works properly.
    However when I create any report (with any Record Type) the fields setup with picklist are displayed only in spanish language even though I am on English mode.
    Have you any reference(s) or previous experience(s) on that?
    Thanks in advance
    Mtb

    Hi,
    in reports the language of the picklists corresponds always to the company default language.
    The only solution I now (its really static and not so nice):
    Create one report per language and change the picklist field by using CASE statements...you see its hard to refresh if you have lots of values :)
    cheers
    Myriam

  • How to display only one row in report when...

    Hi,
      I've a report display in which i've 3 fields EBELN, LIFNR , MENGE. EBELN, LIFNR are from EKKO table and MENGE id from EKPO table .
             On clicking the EBELN there will be getting another report in which we get EBELN,EBELP and MATNR and MENGE from EKPO table .
           The problem is while displaying 1st report if the purchase order has two items in EKPO table then its displaying two times. How can i get only one time and the MENGE should be sum of those two item prices.

    hi use the statement not to get the  multiple items..
    sort itab by ebeln.
    delete adjacent duplicates from itab comparing vbeln.
    i will give u an example to get the total and subtotal ....
    *& Report  ZR_A1
    REPORT  ZR_A1
            NO STANDARD PAGE HEADING.
    Tables declarations
    TABLES: VBAK, VBAP.
    Variable declarations
    DATA: C1 TYPE C.
    Internal Table declarations*
    DATA: BEGIN OF IT_VBAK OCCURS 0,
          VBELN LIKE VBAK-VBELN,
          VKORG LIKE VBAK-VKORG,
          VTWEG LIKE VBAK-VTWEG,
          SPART LIKE VBAK-SPART,
          END OF IT_VBAK.
    DATA: BEGIN OF IT_VBAP OCCURS 0,
          VBELN LIKE VBAP-VBELN,
          POSNR LIKE VBAP-POSNR,
          MATNR LIKE VBAP-MATNR,
          NETWR LIKE VBAP-NETWR,
          BRGEW LIKE VBAP-BRGEW,
          NTGEW LIKE VBAP-NTGEW,
          END OF IT_VBAP.
    DATA: BEGIN OF IT_FINAL OCCURS 0,
          VBELN LIKE VBAK-VBELN,
          VKORG LIKE VBAK-VKORG,
          VTWEG LIKE VBAK-VTWEG,
          SPART LIKE VBAK-SPART,
          POSNR LIKE VBAP-POSNR,
          MATNR LIKE VBAP-MATNR,
          NETWR LIKE VBAP-NETWR,
          BRGEW LIKE VBAP-BRGEW,
          NTGEW LIKE VBAP-NTGEW,
    END OF IT_FINAL.
    Selection-screen design
    SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-R01.
    SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
    SELECTION-SCREEN: END OF BLOCK B1.
    TOP-OF-PAGE.
    FORMAT INTENSIFIED ON COLOR 5.
    WRITE:/7 'LIST TO DISPLAY SALES ITEM INFO'.
    START-OF-SELECTION.
    Populating it_vbak table
    SELECT VBELN
           VKORG
           VTWEG
           SPART
           FROM VBAK
           INTO TABLE IT_VBAK
           WHERE VBELN IN S_VBELN.
    populating it_vbap table
    IF NOT IT_VBAK[] IS INITIAL.
    SELECT  VBELN
            POSNR
            MATNR
            NETWR
            BRGEW
            NTGEW
            FROM VBAP
            INTO TABLE IT_VBAP
            FOR ALL ENTRIES IN IT_VBAK
            WHERE VBELN = IT_VBAK-VBELN.
    ENDIF.
    populating the final list
    LOOP AT IT_VBAP.
    READ TABLE IT_VBAK WITH KEY VBELN = IT_VBAP-VBELN.
    IF SY-SUBRC = 0.
    MOVE:  IT_VBAK-VBELN TO IT_FINAL-VBELN,
           IT_VBAK-VKORG TO IT_FINAL-VKORG,
           IT_VBAK-VTWEG TO IT_FINAL-VTWEG,
           IT_VBAK-SPART TO IT_FINAL-SPART,
           IT_VBAP-POSNR TO IT_FINAL-POSNR,
           IT_VBAP-MATNR TO IT_FINAL-MATNR,
           IT_VBAP-NETWR TO IT_FINAL-NETWR,
           IT_VBAP-BRGEW TO IT_FINAL-BRGEW,
           IT_VBAP-NTGEW TO IT_FINAL-NTGEW.
    APPEND IT_FINAL.
    ENDIF.
    ENDLOOP.
    SORT IT_FINAL BY VBELN.
    LOOP AT IT_FINAL.
    AT FIRST.
    FORMAT INTENSIFIED ON COLOR 1.
    WRITE:/35 'SALES DOCUMENT ITEM LIST'.
    ULINE AT (100).
    *endat.
    FORMAT INTENSIFIED ON COLOR 5.
    WRITE:/ SY-VLINE,
          2  'SALES.DOCU.NO',
          13 'ITEM',
          21 'MATERIAL',
          50 'NET-VAL',
          65 'GROSS-WT',
          82 'NET-WT',
          100 SY-VLINE.
    ENDAT.
    FORMAT INTENSIFIED ON COLOR 2.
    WRITE:/ SY-VLINE,
           2   C1 AS CHECKBOX,
           5 IT_FINAL-VBELN,
          13  IT_FINAL-POSNR,
          21  IT_FINAL-MATNR,
          41  IT_FINAL-NETWR,
          56  IT_FINAL-BRGEW,
          71  IT_FINAL-NTGEW,
          100 SY-VLINE.
    AT END OF VBELN.
    SUM.
    FORMAT INTENSIFIED ON COLOR 3.
    WRITE:/    SY-VLINE,
             30   'SUB-TOTAL:',
             41   IT_FINAL-NETWR,
             56   IT_FINAL-BRGEW,
             71   IT_FINAL-NTGEW.
       WRITE:/100 SY-VLINE.
    ENDAT.
    AT LAST.
    SUM.
    FORMAT INTENSIFIED ON COLOR 6.
    WRITE:/ SY-VLINE,
              30  'GRAND-TOTAL:',
              41  IT_FINAL-NETWR,
              56  IT_FINAL-BRGEW,
              71  IT_FINAL-NTGEW.
      WRITE:/100  SY-VLINE.
      ENDAT.
      ENDLOOP.
    regards,
    venkat .

  • (2) Vehicles - But want to have only ONE FOB for keyless entry and remote start

    I have the following 2 vehicles:
    2003 Dodge Durango RT with automatic transmission
    2006 Volvo V70R with 6-Speed manual transmission
    I am looking to purchase a keyless entry / remote start on BOTH vehicles but use only (1) FOB to control both as I will only be using either vehicle at a time. If I need to use both, I will use 2 FOBs. Is there any current breand or system that can do this, like have switch and can be programmed for more than one vehicles ??? Thank you for any info and God Bless !!!
    Solved!
    Go to Solution.

    VBVAGUY,
    Best Buy has 2 brands that can control 2 cars. Viper and Compustar. You said you would like keyless and remotes start. Are these the only features you are looking for? Security? The system below is a Viper 1-way with around 2000 foot range that offers 2 car mode. They also have a 1 mile range and also a 2-way system. This is a nice feature if you don't have visibility to the vehicle, the remote will tell you if the car started.
    http://www.bestbuy.com/site/viper-1-way-remote-sta​rt-system/6891137.p?id=1218810613502&skuId=6891137
    With any of these system you are also going to need some additional parts and labor. Also because the Volvo has a manual transmission there is a certain sequence you must do every time you park the vehicle. If this is not done the remote start will not work. Doesn't effect the keyless entry.
    Stop in a local Best Buy and speak to the AutoTech. They can educate you on the different model, feature and the manual transmission sequence.

  • Multi-column Index vs One index for each column

    Hello everyone,
    i have one table about 20 000 000 rows, some developers have to generate reports on it and i want to create indexes on this table.
    The table has 34 columns, no primary key, no unique keys.
    The "where..." clause of the reports usually use 8 columns but some reports uses 8 + some other columns.
    can any one help me on what kind of indexes do i have to create?
    1. one index for each column used in "where clause"
    2. one index for 8 columns and some other indexes for other used columns
    3. one index for all columns
    or something else etc...
    br flag

    i have one table about 20 000 000 rows, some developers have to generate reports on it and i want to create indexes on this table.
    The table has 34 columns, no primary key, no unique keys.
    The "where..." clause of the reports usually use 8 columns but some reports uses 8 + some other columns.
    can any one help me on what kind of indexes do i have to create?
    1. one index for each column used in "where clause"
    2. one index for 8 columns and some other indexes for other used columns
    3. one index for all columns
    or something else etc...What's the version of your data base? what kind of database you have, DWH or OTLP? The answer might depend on the type of database as far as bitmap indexes might suit or might not depending if you are runing DWH or OLTP kind of database
    Let me suppose that you are runing OLTP database and you have a where clause with 8 columns.
    1) are all those where clause equalities (where col1 = and col2 =) or there are inequalities?
    2) could you evaluate the most repetitive columns?
    3) could you know the column that could have the best clustering factor (the column which most follow a certain order in the table)
    Based on that I would suggest to create one b-tree index having 8 columns (even though that it seems for me to high) this index should follow the following points:
    1) put the most repetitive column at the leading edge (and compress the index if necessary)
    2) put the columns that are used in equalitity predicate first
    3) put the column having the best clustering factor first
    The most precise index you have the best access you could gain.
    Of course that you have to know that an index access is not always good and a FULL table scan is not always bad.
    Best regards
    Mohamed Houri
    www.hourim.wordpress.com

  • More than one index for a column.

    Hi,
    I am trying to create more than one index for a particular column of the table.But oracle does not allow more than one index for a column.
    I just want to make sure whether we can add more than one index for a column
    and if yes what are the scenarios.
    Because as far as i know some database allows more than one index for a single column.

    You cannot create more than one index for the same column(s).This is not so true Nicolas. Look at following example:
    SQL> create index idx_mytest_id on mytest(id);
    Index created.
    SQL> create index idx_mytest_id_desc on mytest(id desc);
    Index created.
    SQL> create index idx_fbi_mytest_id_upper on mytest(upper(id));
    Index created.
    SQL> create index idx_fbi_mytest_id_upper_desc on mytest(upper(id) desc);
    Index created.
    SQL> create index idx_fbi_mytest_id_lower_id on mytest(lower(id));
    Index created.
    SQL> create index idx_fbi_mytest_id_lower_id_dsc on mytest(lower(id) desc);
    Index created.
    SQL> create index idx_fbi_mytest_id_tr_up on mytest(trunc(upper(id)));
    Index created.
    -- I can still continue but for this example this will be enough
    SQL> select index_name from dba_indexes where table_name = 'MYTEST';
    INDEX_NAME                                                                                                    
    IDX_MYTEST_ID                                                                                                 
    IDX_FBI_MYTEST_ID_UPPER                                                                                       
    IDX_MYTEST_ID_DESC                                                                                            
    IDX_FBI_MYTEST_ID_UPPER_DESC                                                                                  
    IDX_FBI_MYTEST_ID_LOWER_ID                                                                                    
    IDX_FBI_MYTEST_ID_LOWER_ID_DSC                                                                                
    IDX_FBI_MYTEST_ID_TR_UP                                                                                       
    7 rows selected.You can see 7 indexes for one column (ID) and I could still continue...
    So according this test we can say you can't create more than one index for one column (or the same group of columns in case of composite index) with same condition(s).
    Message was edited by:
    Ivan Kartik
    Or simplified: you can't create the same index for same column(s) twice :-)

  • Can I use only one computer for driver development?

    Hi! I'm newbie in driver development and now is first day when I make the acquaintance of driver development. There is the next phrase in MSDN in
    https://msdn.microsoft.com/en-us/library/windows/hardware/hh706187(v=vs.85).aspx
    : "For developing, debugging, and installing a kernel-mode driver, you need two computers". But I unfortunately have only one computer and I have to develop the USB Kernel Mode driver as technical assignment for admission to the job.
    My computer is under Windows 7 OS and already has standard USB driver. I have Visual Studio 2013 Ultimate and WDK 8.1 Update on my computer. Can I use only one computer for driver development and debugging or not?

    no, not really, you need two. you can use a VM as the machine under test though.
    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

  • Get only one row for each kind of a column

    hi there!
    i have a little problem.
    I have a table with 10 columns. One of them has repeated values. My goal is to get all the rows with this column only one time for each values that it has.
    Ex:
    Col1 Col2 Col3
    A A A
    B B B
    C A C
    D C D
    Column 2 has repeated values. My goal is to get:
    A A A
    B B B
    D C D
    Only one time each value of column 2.
    Thanks guys! ;)

    SQL>  CREATE TABLE Tbl (col1 VARCHAR2(1),col2 VARCHAR2(1),col3 VARCHAR2(1));
    Table created.
    SQL> INSERT INTO Tbl VALUES ('A','A','A');
    1 row created.
    SQL>              INSERT INTO Tbl VALUES ('B','B','B');
    1 row created.
    SQL>              INSERT INTO Tbl VALUES ('C','A','C');
    1 row created.
    SQL>              INSERT INTO Tbl VALUES ('D','C','D');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> SELECT * FROM tbl t1
      2  WHERE
      3  rowid=(SELECT min(rowid)
      4         FROM tbl t2
      5         WHERE t1.col2=t2.col2);
    C C C
    A A A
    B B B
    D C D
    SQL> SELECT * FROM tbl t1
      2  WHERE
      3  rowid=(SELECT max(rowid)
      4         FROM tbl t2
      5         WHERE t1.col2=t2.col2);
    C C C
    B B B
    C A C
    D C DEdited by: Saubhik on Aug 3, 2010 1:31 AM

  • I have a mixer which i was using with my pc and now i bought a new macbook and it have only one jack for headphones and to use mixers i need jack for microphone too so what should i do

    i have a mixer which i was using with my pc and now i bought a new macbook and it have only one jack for headphones and to use mixers i need jack for microphone too so what should i do

    You need to get headset splitter adapter.
    http://www.startech.com/Cables/Audio-Video/Audio-Cables/35mm-4-Position-to-2x-3- Position-35mm-Headset-Splitter-Adapter-Male-to-Female~MUYHSMFF

  • Just bought Photoshop Elements 12 and Photoshop Elements 12 Premiere...downloaded with Akamai Download Manager...now cannot find!  Where to look?  Have Mac OS...looked in downloads already...only one site for Photoshop Elements 12...nothing about Premiere

    Just bought Photoshop Elements 12 and Photoshop Elements 12 Premiere...downloaded with Akamai Download Manager...now cannot find!  Where to look?  Have Mac OS...looked in downloads already...only one site for Photoshop Elements 12...nothing about Premiere..when click on Install says Adobe already running...Really?  Where is it?

    restart you computer and use finder to check for downloaded/installed files.

  • HT204053 i am having iphone3gs and ipod4s, is it possible the application that i have purchased in my iphone can be available in my i pod by doing payment only one time for the same application in my i phone...if yes,plz let me know hw it is possible

    i am having iphone3gs and ipod4s, is it possible the application that i have purchased in my iphone can be available in my i pod by doing payment only one time for the same application in my i phone...if yes,plz let me know hw it is possible..

    Open the App Store on your device.
    Make sure you are signed in with the same account used for the original purchase.
    Tap on Purchased from the bottom navigation bar.
    On iPhone or iPod touch, tap Updates from the bottom navigation bar, then tap Purchased.
    Locate the app in your Purchased tab.
    Tap the download button (cloud symbol)
    See also: http://support.apple.com/kb/HT2519?viewlocale=en_US&locale=en_US

  • Oracle database link to MySQL select only one row

    Hello,
    I have created a connection from the Oracle batabase 11.2 to a MySQL database via database link. The following statement shows, that 35 rows are in the mySQL table:
    SQL>  select count(*) from "main_pages"@MOREWEB;
      COUNT(*)
            35
    But a normal select statement only return 1 row.
    SQL> select "subject" from "main_pages"@MOREWEB;
    subject
    Übersicht: Referenzen
    I am using the mysql-connector-odbc-3.51.30-winx64 driver. A newer version cann't be installed because on Windows Server 2008 R2 I get an error with an missing dll-file. The DataDirect-ODBC-driver is not possible, because we like to use the free MySQL-database an DataDirect only support the enterprise edition.
    I also have tried to limit the HS_OPEN_CURSORS or dont limit the HS_FDS_FETCH_ROWS, but there is no difference in the result. I always get only one row.
    HS Init.ora
    # This is a sample agent init file that contains the HS parameters that are
    # needed for the Database Gateway for ODBC
    # HS init parameters
    HS_FDS_CONNECT_INFO = moreweb
    HS_FDS_TRACE_LEVEL = ON
    HS_FDS_FETCH_ROWS=1
    # Environment variables required for the non-Oracle system
    #set <envvar>=<value>
    HS tracefile
    Oracle Corporation --- MITTWOCH   NOV 05 2014 13:56:22.066
    Heterogeneous Agent Release
    11.2.0.1.0
    Oracle Corporation --- MITTWOCH   NOV 05 2014 13:56:22.066
        Version 11.2.0.1.0
    HOSGIP for "HS_FDS_TRACE_LEVEL" returned "ON"
    HOSGIP for "HS_OPEN_CURSORS" returned "50"
    HOSGIP for "HS_FDS_FETCH_ROWS" returned "1"
    HOSGIP for "HS_LONG_PIECE_TRANSFER_SIZE" returned "65536"
    HOSGIP for "HS_NLS_NUMERIC_CHARACTER" returned ".,"
    HOSGIP for "HS_KEEP_REMOTE_COLUMN_SIZE" returned "OFF"
    HOSGIP for "HS_FDS_DELAYED_OPEN" returned "TRUE"
    HOSGIP for "HS_FDS_WORKAROUNDS" returned "0"
    HOSGIP for "HS_FDS_MBCS_TO_GRAPHIC" returned "FALSE"
    HOSGIP for "HS_FDS_GRAPHIC_TO_MBCS" returned "FALSE"
    HOSGIP for "HS_FDS_RECOVERY_ACCOUNT" returned "RECOVER"
    HOSGIP for "HS_FDS_TRANSACTION_LOG" returned "HS_TRANSACTION_LOG"
    HOSGIP for "HS_FDS_TIMESTAMP_MAPPING" returned "DATE"
    HOSGIP for "HS_FDS_DATE_MAPPING" returned "DATE"
    HOSGIP for "HS_FDS_CHARACTER_SEMANTICS" returned "FALSE"
    HOSGIP for "HS_FDS_MAP_NCHAR" returned "TRUE"
    HOSGIP for "HS_FDS_RESULTSET_SUPPORT" returned "FALSE"
    HOSGIP for "HS_FDS_RSET_RETURN_ROWCOUNT" returned "FALSE"
    HOSGIP for "HS_FDS_PROC_IS_FUNC" returned "FALSE"
    HOSGIP for "HS_FDS_REPORT_REAL_AS_DOUBLE" returned "FALSE"
    using mpgw as default value for "HS_FDS_DEFAULT_OWNER"
    HOSGIP for "HS_SQL_HANDLE_STMT_REUSE" returned "FALSE"
    SQL text from hgopars, id=1, len=36 ...
         00: 53454C45 43542043 4F554E54 282A2920  [SELECT COUNT(*) ]
         10: 46524F4D 20606D61 696E5F70 61676573  [FROM `main_pages]
         20: 60204131                             [` A1]
    Deferred open until first fetch.
    Performing delayed open.
    SQL text from hgopars, id=1, len=40 ...
         00: 53454C45 43542041 312E6073 75626A65  [SELECT A1.`subje]
         10: 63746020 46524F4D 20606D61 696E5F70  [ct` FROM `main_p]
         20: 61676573 60204131                    [ages` A1]
    Deferred open until first fetch.
    Performing delayed open.
    Please can help me someone.
    Thanks.
    Bianca

    mxallen wrote:
    Bianca,
    If you log directly into MySQL and issue the same query (select "subject" from "main_pages";) what data is returned?
    I looks to me that you count is the number of rows in the entire table "main_pages"
    while you select is for the data in the "subject" column only.
    This seems to indicate that you have just one row in that subject column.
    Regards,
    Matt
    WHAATT?
    What do you mean by "just one row in that subject column"?
    That makes no sense at all.  A row is a row.  A column is a part of a row.  All rows have all columns, though not all columns of all rows will necessarily have an assigned value.  Lacking a WHERE clause to filter rows, any SELECT should return all rows.

  • SQL Server 2012 Undetected Deadlock in a table with only one row

      We have migrated our SQL 2000 Enterprise Database to SQL 2012 Enterprise few days ago.
      This is our main database, so most of the applications access it.
      The day after the migration, when users started to run tasks, the database access started to experiment a total failure.
      That is, all processes in the SQL 2k12 database were in lock with each other. This is a commom case of deadlock, but the Database Engine was unable to detect it.
      After some research, we found that the applications were trying to access a very simple table with only one row. This table has a number that is restarted every day and is used to number all the transactions made against the system.   So, client
    applications start a new transaction, get the current number, increment it by one and commit the transaction.
      The only solution we found was to kill all user processes in SQL Server every time this situation occurs (no more than 5 minutes when all clients are accessing the database).
      No client application was changed in this migration and this process was working very well for the last 10 years.
      The problem is that SQL 2k12 is unable to handle this situation compared to SQL 2k.
      It seems to occurs with other tables too, but as this is an "entry table" the problem occurs with it first.
      I have searched internet and some suggest some workarounds like using table hints to completely lock the table at the begining of the transaction, but it can't be used to other tables.
      Does anyone have heard this to be a problem with SQL 2k12? Is there any fixes to make SQL 2k12 as good as SQL 2k?

    First off re: "Unfortunatelly, this can't be used in production environment as exclusive table lock would serialize the accesses to tables and there will be other tables that will suffer with this problem."
    This is incorrect. 
    Using a table to generate sequence numbers like this is a bad idea exactly because the access must be serialized.  Since you can't switch to a SEQUENCE object, which is the correct solution, the _entire goal_ of this exercise to find a way to properly
    serialize access to this table.  Using exclusive locking will not be necessary for all the tables; just for the single-row table used for generating sequence values with a cursor.
    I converted the sample program to VB.NET:
    Public Class Form1
    Private mbCancel As Boolean = False
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim soConn As ADODB.Connection
    Dim soRst As ADODB.Recordset
    Dim sdData As Date
    Dim slValue As Long
    Dim slDelay As Long
    'create database vbtest
    'go
    ' CREATE TABLE [dbo].[ControlNumTest](
    ' [UltData] [datetime] NOT NULL,
    ' [UltNum] [int] NOT NULL,
    ' CONSTRAINT [PK_CorreioNumTeste] PRIMARY KEY CLUSTERED
    ' [UltData] Asc
    ' )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY]
    ' ) ON [PRIMARY]
    mbCancel = False
    Do
    ' Configure the Connection object
    soConn = New ADODB.Connection
    With soConn
    .ConnectionString = "Provider=SQLNCLI11;Initial Catalog=vbtest;Data Source=localhost;trusted_connection=yes"
    .IsolationLevel = ADODB.IsolationLevelEnum.adXactCursorStability
    .Mode = ADODB.ConnectModeEnum.adModeReadWrite
    .CursorLocation = ADODB.CursorLocationEnum.adUseServer
    .Open()
    End With
    ' Start a new transaction
    Call soConn.BeginTrans()
    ' Configure the RecordSet object
    soRst = New ADODB.Recordset
    With soRst
    .ActiveConnection = soConn
    .CursorLocation = ADODB.CursorLocationEnum.adUseServer
    .CursorType = ADODB.CursorTypeEnum.adOpenForwardOnly
    .LockType = ADODB.LockTypeEnum.adLockPessimistic
    .Open("SELECT * FROM dbo.ControlNumTest")
    End With
    With soRst
    sdData = .Fields!UltData.Value ' Read the last Date (LOCK INFO 1: See comments bello
    slValue = .Fields!UltNum.Value ' Read the last Number
    If sdData <> Date.Now.Date Then ' Date has changed?
    sdData = Date.Now.Date
    slValue = 1 ' Restart number
    End If
    .Fields!UltData.Value = sdData ' Update data
    .Fields!UltNum.Value = slValue + 1 ' Next number
    End With
    Call soRst.Update()
    Call soRst.Close()
    ' Ends the transaction
    Call soConn.CommitTrans()
    Call soConn.Close()
    soRst = Nothing
    soConn = Nothing
    txtUltNum.Text = slValue + 1 ' Display the last number
    Application.DoEvents()
    slDelay = Int(((Rnd * 250) + 100) / 100) * 100
    System.Threading.Thread.Sleep(slDelay)
    Loop While mbCancel = False
    If mbCancel = True Then
    Call MsgBox("The test was canceled")
    End If
    Exit Sub
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    mbCancel = True
    End Sub
    End Class
    And created the table
    CREATE TABLE [dbo].[ControlNumTest](
    [UltData] [datetime] NOT NULL,
    [UltNum] [int] NOT NULL,
    CONSTRAINT [PK_CorreioNumTeste] PRIMARY KEY CLUSTERED
    [UltData] Asc
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = on, FILLFACTOR = 80) ON [PRIMARY]
    ) ON [PRIMARY]
    go insert into ControlNumTest values (cast(getdate()as date),1)
    Then ran 3 copies of the program and generated the deadlock:
    <deadlock>
    <victim-list>
    <victimProcess id="processf27b1498" />
    </victim-list>
    <process-list>
    <process id="processf27b1498" taskpriority="0" logused="0" waitresource="KEY: 35:72057594039042048 (a01df6b954ad)" waittime="1970" ownerId="3181" transactionname="implicit_transaction" lasttranstarted="2014-02-14T15:49:31.263" XDES="0xf04da3a8" lockMode="X" schedulerid="4" kpid="9700" status="suspended" spid="51" sbid="0" ecid="0" priority="0" trancount="2" lastbatchstarted="2014-02-14T15:49:31.267" lastbatchcompleted="2014-02-14T15:49:31.267" lastattention="1900-01-01T00:00:00.267" clientapp="vbt" hostname="DBROWNE2" hostpid="21152" loginname="NORTHAMERICA\dbrowne" isolationlevel="read committed (2)" xactid="3181" currentdb="35" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128058">
    <executionStack>
    <frame procname="adhoc" line="1" stmtstart="80" sqlhandle="0x020000008376181f3ad0ea908fe9d8593f2e3ced9882f5c90000000000000000000000000000000000000000">
    UPDATE [dbo].[ControlNumTest] SET [UltData]=@Param000004,[UltNum]=@Param000005 </frame>
    <frame procname="unknown" line="1" sqlhandle="0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000">
    unknown </frame>
    </executionStack>
    <inputbuf>
    (@Param000004 datetime,@Param000005 int)UPDATE [dbo].[ControlNumTest] SET [UltData]=@Param000004,[UltNum]=@Param000005 </inputbuf>
    </process>
    <process id="processf6ac9498" taskpriority="0" logused="10000" waitresource="KEY: 35:72057594039042048 (a01df6b954ad)" waittime="1971" schedulerid="5" kpid="30516" status="suspended" spid="55" sbid="0" ecid="0" priority="0" trancount="1" lastbatchstarted="2014-02-14T15:49:31.267" lastbatchcompleted="2014-02-14T15:49:31.267" lastattention="1900-01-01T00:00:00.267" clientapp="vbt" hostname="DBROWNE2" hostpid="27852" loginname="NORTHAMERICA\dbrowne" isolationlevel="read committed (2)" xactid="3182" currentdb="35" lockTimeout="4294967295" clientoption1="671156256" clientoption2="128058">
    <executionStack>
    <frame procname="adhoc" line="1" sqlhandle="0x020000003c6309232ab0edbe0a7790a816a09c4c5ac6f43c0000000000000000000000000000000000000000">
    FETCH API_CURSOR0000000000000001 </frame>
    <frame procname="unknown" line="1" sqlhandle="0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000">
    unknown </frame>
    </executionStack>
    <inputbuf>
    FETCH API_CURSOR0000000000000001 </inputbuf>
    </process>
    </process-list>
    <resource-list>
    <keylock hobtid="72057594039042048" dbid="35" objectname="vbtest.dbo.ControlNumTest" indexname="PK_CorreioNumTeste" id="lockff6e6c80" mode="U" associatedObjectId="72057594039042048">
    <owner-list>
    <owner id="processf6ac9498" mode="S" />
    <owner id="processf6ac9498" mode="U" requestType="wait" />
    </owner-list>
    <waiter-list>
    <waiter id="processf27b1498" mode="X" requestType="convert" />
    </waiter-list>
    </keylock>
    <keylock hobtid="72057594039042048" dbid="35" objectname="vbtest.dbo.ControlNumTest" indexname="PK_CorreioNumTeste" id="lockff6e6c80" mode="U" associatedObjectId="72057594039042048">
    <owner-list>
    <owner id="processf27b1498" mode="U" />
    <owner id="processf27b1498" mode="U" />
    <owner id="processf27b1498" mode="X" requestType="convert" />
    </owner-list>
    <waiter-list>
    <waiter id="processf6ac9498" mode="U" requestType="wait" />
    </waiter-list>
    </keylock>
    </resource-list>
    </deadlock>
    It's the S lock that comes from the cursor read that's the villian here.  U locks are compatible with S locks, so one session gets a U lock and another gets an S lock.  But then the session with an S needs a U, and the session with a U needs an
    X.  Deadlock. 
    I'm not sure what kind of locks were taken by this cursor code on SQL 2000, but on SQL 2012, this code is absolutely broken and should deadlock.
    The right way to fix this code is to add (UPDLOCK,SERIALIZABLE) to the cursor
    .Open("SELECT * FROM dbo.ControlNumTest with (updlock,serializable)")
    So each session reads the table with a restrictive lock, and you don't mix S, U and X locks in this transaction.  This resolves the deadlock, but requires a code change.
    I tried several things that didn't require a code, which did not resolve the deadlock;
    1) setting ALLOW_ROW_LOCKS=OFF ALLOW_PAGE_LOCKS=OFF
    2) SERIALIZABLE isolation level
    3) Switching OleDB providers from SQLOLEDB to SQLNCLI11
    Then I replaced the table with a view containing a lock hint:
    CREATE TABLE [dbo].[ControlNumTest_t](
    [UltData] [datetime] NOT NULL,
    [UltNum] [int] NOT NULL,
    CONSTRAINT [PK_CorreioNumTeste] PRIMARY KEY CLUSTERED
    [UltData] Asc
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = on, FILLFACTOR = 80) ON [PRIMARY]
    ) ON [PRIMARY]
    go
    create view ControlNumTest as
    select * from ControlNumTest_t with (tablockx)
    Which, at least in my limited testing, resovlved the deadlock without any client code change.
    David
    David http://blogs.msdn.com/b/dbrowne/

Maybe you are looking for

  • Help, Cannot connect to ODBC database using SQL Toolkit!

    Hello All, I am toying around with the SQL Toolkit evaluation (2.2 + the patch) and I am having difficulty. I ran the example program "connect" and it seems to work fine. However, I try to write my own program and I keep getting the same message: "Fu

  • Network accounts doesn't create

    Hi. When I create a network account in server.app and set its permissions to services it all looks fine. When I look into Workgroup Mgr I can see the account. When I go to the location of my home folder, the account doesn't show up. I have created ne

  • Some PDF covers are not displayed in iTunes

    Hi, I´m importing epub and pdf files into iTunes. Epub in general workes fine. Some of the imported PDF do not show a cover. I have done so many thinks but I have no idea why those file are having a problem: - changd the picture - changed the pdf add

  • How should i increase over all buffer hit ratio.....

    Hi all, As shown below if my DB2 databse buffer Qulaity is low .. How should i increase over all buffer hit ratio.. Please advice on any sap standrd notes or procedures Number                                    1 Total Size                          

  • Lync 2013 basic client msi

    Hi all, Anyone knows where can I find .msi file for Lync 2013 basic client? Microsoft website only have .exe which doesn't work with GPO software deployment. Thanks