Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.
dupicate occure following this sp

Answered dupicate occure following this sp

  • Tuesday, February 12, 2013 7:08 AM
     
     

    Hi

    I having a one issue using for sp...

    IF(LEN(@AssetCode) <> 0)
    BEGIN
    SELECT LU.LoadCode, LU.LoadText,LU.LoadValue ,
    TSR.sources,TSR.sourceCount,Remarks 
    FROM V_ADM_Load LU
    LEFT OUTER JOIN AssetCountRegister TSR 
    on TSR.Resources = LU.LoadValue
    WHERE LU.CategoryName = 'source' AND lu.IsAlive = 'Y' 
    ORDER BY DisplayOrder
    END

    While using this sp. i got dupicate records. Iam using this sp in two places. one add a new item and then edit item. Can any one guide me how to slove this issue

All Replies

  • Tuesday, February 12, 2013 7:16 AM
     
     
    Can you give sample data and DDL of the tables?

    Thanks Sarat --Please use Marked as Answer if my post solved your problem and use Vote As Helpful if the post was useful.

  • Tuesday, February 12, 2013 7:44 AM
     
     

    LoadCode                     LoadCategory                 LoadCategoryName                                 LoadText                     Loadvalue DisplayOrder                            IsAlive
    ------------------------------ ------------------------------ -------------------------------------------------- ------------------------------ ------------------------------ ---------------
    LUM00000080046                 LUC00000070012                 source                                           Bath Towel                     BT                             1.00                                   Y 
    LUM00000080048                 LUC00000070012                 source                                           Face Towel                     FT                             2.00                                    Y
    LUM00000080049                 LUC00000070012                 source                                           Hand Towel                     HT                             300.00                                  Y
    LUM00000080050                 LUC00000070012                 source                                           Foot Towel                     FT                             4.00                                    Y
    LUM00000080051                 LUC00000070012                 source                                           Kimono kerah V                 KKV                            5.00                                    Y
    LUM00000080052                 LUC00000070012                 source                                           Kimono Ikat                    KI                             6.00                                    Y
    LUM00000080053                 LUC00000070012                 source                                           Sarung bantal satin besar      SBSB                           7.00                                    Y
    LUM00000080054                 LUC00000070012                 source                                           Sarung bantal satin kecil      SBSK                           8.00                                    Y
    LUM00000080055                 LUC00000070012                 source                                           Sarung bantal coklat (Refleksi SBC                            9.00                                    Y
    LUM00000080056                 LUC00000070012                 source                                           Sarung bantal warna            SBW                            10.00                                   Y
    LUM00000080057                 LUC00000070012                 source                                           Bed sheet VIP kecil            BSVK                           11.00                                   Y
    LUM00000080058                 LUC00000070012                 source                                           Bed sheet man w/head           BSW                            12.00                                   Y
    LUM00000080059                 LUC00000070012                 source                                           Bed sheet thai                 BSThai                         13.00                                   Y
    LUM00000080060                 LUC00000070012                 source                                           Bed sheet VIP besar            BSVB                           14.00                                   Y
    LUM00000080061                 LUC00000070012                 source                                           Wall decoration batik          WDB                            15.00                                   Y
    LUM00000080062                 LUC00000070012                 source                                           Bed cover satin decoration     BCSD                           16.00                                   Y
    LUM00000080063                 LUC00000070012                 source                                           Sarung bantal Thai besar       SBTB                           17.00                                   Y
    LUM00000080064                 LUC00000070012                 source                                           Sarung Bantal Thai kecil       SBTK                           18.00                                   Y
    LUM00000080065                 LUC00000070012                 source                                           Sarung guling thai             SGT                            19.00                                   Y
    LUM00000080066                 LUC00000070012                 source                                           Sarung Bantal Thai kecil       SBTK                           20.00                                   Y
    LUM00000080067                 LUC00000070012                 source                                           Bed for Woman                  BTW                            21.00                                   Y
    LUM00000080068                 LUC00000070012                 source                                           Bed satin for Thai             BSFT                           22.00                                   Y
    LUM00000080069                 LUC00000070012                 source                                           Wash lap                       WL                             23.00                                   Y

  • Tuesday, February 12, 2013 8:47 AM
    Moderator
     
     
    I see that you did not use the @AssetCode parameter in WHERE clause of SELECT statement, I thought it is related with the SELECT

    SQL Server, SQL Server 2012 Denali and T-SQL Tutorials

  • Tuesday, February 12, 2013 8:49 AM
     
     

    Hi,

    It seems there is no duplicated values. Duplicated rows means 2 or more rows are having the same values for all columns.

    Or you can consider to group by specific columns, and then use aggregate functions for other columns, upon your needs.


    Many Thanks & Best Regards, Hua Min

  • Tuesday, February 12, 2013 9:40 AM
     
     Answered
    It seems like you have the same "LoadValue" for two different items. Both FaceTowel and FootTowel have the LoadValue FT. Since you have this as a JOIN criteria, it could lead to the row being joined twice.

    Steen Schlüter Persson (DK)

    • Marked As Answer by SSK_0105 Wednesday, February 13, 2013 4:28 AM
    •  
  • Tuesday, February 12, 2013 10:42 AM
     
     

    Try to put WHERE Condition in to Join Condition.

    IF(LEN(@AssetCode) <> 0)
    BEGIN
    SELECT LU.LoadCode, LU.LoadText,LU.LoadValue ,
    TSR.sources,TSR.sourceCount,Remarks 
    FROM V_ADM_Load LU
    LEFT OUTER JOIN AssetCountRegister TSR
    on TSR.Resources = LU.LoadValue
    and LU.CategoryName = 'source' AND lu.IsAlive = 'Y'
    ORDER BY DisplayOrder
    END


    -- Bhavesh Thakkar

    Sr.Database Administrator
    My Blog
    Linked In Profile