Compair between string into Store Procedure

  • Hello friends please if you can support me as I'm trying to make a comparison of strings but it seems that something is missing me , I have tried to create the following code but apparently something missing syntax

    IF

    (

    ( SELECT slastname1 + '' + slastname2 + '' + sname + ' ' FROM WHERE DOBLEPER IdPrincipal = @ IdPrincipal ) =

    ( SELECT slastname1 + '' + slastname2 + '' + sname + ' ' FROM WHERE DOBLEPER IdSecundario = @ IdSecundario )

    )

    ELSE

    END

    My table has the following structure: (Father , Mother , Name are varchar type ) as seen in the table the person Perez Garcia Jorge has 2 codes Id 's which is not correct for this reason we will have a process through a SP only where the record has an ID This (Table A) is generated by other query and for that reason I filter only those records that have 2 ids codes . The table can have 50,000 records and I can not validate the IdPrincipal and IdSecundario if they refer to the same record for the 50 000 records having my table

    (Table A)

    Lastname1- Lastname2 - Name - Age - IdPrincipal - IdSecundario

    PEREZ - GARCIA - JORGE - 20 - ABABABABAB - CDCDCDCDCD

    Quispe - LOPEZ - JOSE - 22 - FGFGFGFGFG - KLKLKLKLKL

    So before the Store Procedure make the bonding process and let me IdPrincipal for each record would previously make a comparison as if between 50 000 records finds a record where IdPrincipal and IdSecundario not refer to the same person; by then completed the process and do not binding , because otherwise the Store Procedure ID's will perform the bonding process which records should not join .

    Sorry about the extent of my post but I wanted to detail it so that the problem is properly understood .

    Thanks in advance for your suggestions.

    regards,

  • Hi and welcome to the forums. In order to help we will need a few things:

    1. Sample DDL in the form of CREATE TABLE statements

    2. Sample data in the form of INSERT INTO statements

    3. Expected results based on the sample data

    Please take a few minutes and read the first article in my signature for best practices when posting questions.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply