Search for a string in multiple columns, then insert into temp table

  • My requeirement is

    Am having a batch_id in table1, based on batch_id having 10 records in table2.

    i.e. batch_id is same for 10 records in table2.

    Table2 columns names

    Record_id | Col1|Col1|Col1|Col1|Col1

    -------------------------------------------------------------------------------------------------

    101NULLNULLNULLCARNULL

    102VehicleNULLNuLLVehicleNULL

    103NULLAutoNULLAutoAuto

    104NULLNULLNULLNULLNULL

    ------------------------------------------------------------------------------------------------

    based on batch_id, take record 101 and search for car until it found, if car found insert record_id, car into temp table.

    next

    search vehicle in record_id 102, insert record_id, vehicle in temp table....

    if any record contains NULL, then it should not insert anything, simply skip.

    Please help me...

    Thanks in Advance

  • Skanda (10/12/2012)


    My requeirement is

    Am having a batch_id in table1, based on batch_id having 10 records in table2.

    i.e. batch_id is same for 10 records in table2.

    Table2 columns names

    Record_id | Col1|Col1|Col1|Col1|Col1

    -------------------------------------------------------------------------------------------------

    101NULLNULLNULLCARNULL

    102VehicleNULLNuLLVehicleNULL

    103NULLAutoNULLAutoAuto

    104NULLNULLNULLNULLNULL

    ------------------------------------------------------------------------------------------------

    based on batch_id, take record 101 and search for car until it found, if car found insert record_id, car into temp table.

    next

    search vehicle in record_id 102, insert record_id, vehicle in temp table....

    if any record contains NULL, then it should not insert anything, simply skip.

    Please help me...

    Thanks in Advance

    Hello and welcome to SSC!

    I'm afraid that you haven't really given us enough to go on there. Remember, we can't see your data, your expected results or your actual results. So without a reproducible script that shows your problem, there isn't much that anyone can do to help you.

    If you could set-up DDL and sample data scripts, along with your expected results, as explained in this article --> http://www.sqlservercentral.com/articles/Best+Practices/61537/ <-- then it'd be much easier to help[/url]. Otherwise, we're only guessing 😉

    Thanks


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • You already have a thread on this topic http://www.sqlservercentral.com/Forums/Topic1371464-392-1.aspx Please don't start a new one.

    The reason your old thread hasn't gotten any comments, is that you haven't provided the requested data.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

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

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