SQL Help

I was going to go through a lot of trial and error but one of you must have this sitting somewhere.  I'd like to insert attributes on mass, I'm assuming to the tx_cust_keyword, based on a constituency. Any SQL you'd like to share?

 

Chris

Parents
  • --This will apply the desired attribute and value to --accounts in a specified list if the attribute/value --combination is not already present.

    declare @list_no int,
                 @attribte_no int,
                 @attribute_value  varchar(5)
       
     
        set @list_no = 22593
        set @attribte_no =  405
        set @attribute_value = '06/07'
    --=======================================--
    --select all from the LIST (FOR CHECKING)--
    --=======================================--
                                                    /*
    SELECT *
        FROM     T_LIST_CONTENTS
            WHERE LIST_NO = @list_no
                                                    */
    --==================================--
    --Create attribute for those in list--
    --==================================--
        INSERT Tx_Cust_Keyword
                (keyword_no,
                customer_no,
                key_value)

            SELECT    @attribte_no,
                customer_no,
                @attribute_value

            FROM T_LIST_CONTENTS
                WHERE LIST_NO = @list_no
                    AND CUSTOMER_NO NOT IN
                            (SELECT CUSTOMER_NO
                               FROM Tx_Cust_Keyword
                                  WHERE keyword_no = @attribte_no
                                    AND key_value = @attribute_value)

     

     

  • Thanks every body!  Good old tessnet-technical.

Reply Children
No Data