Dynamically Populate Missing Values

  • Hi All,

    Trust we are doing good, needed help on this. I am getting two excel files that contain duplicate data ( Risk and claims ) however, the only way for me to get a unique key from each file will be to concatenate various columns once the data is in SQL Database.

    I am using the combination of the policy number, Address, Sub location number, county and zip to make the unique key

    These files are imported into SQL database but the SUB LOCATION NUMBER column is sometimes null.

    Want i want is how do i get this column populated when there are null values..

    at seen in the screen shot, there will be duplicate records ( from policy, address, zip etc ) but the sub location number should be pre populated where it is null and in the case of multiple records , then the first record should be 1 then the next 2 and so on..

    where they are one record and sub location is null then that column should be 1.

    Is there a way i can achieve this ( i need to get the merge column populated , i can use concatenate function in sql but i am struggling to pre populate this sub location column)

    Any Help will be appreciated.

    screen shot explain what i need, i need to achieve the values in red

     

    Attachments:
    You must be logged in to view attached files.
  • If you're going to generate an artificial primary key, then why not go all the way and use an identity column or GUID?  It would be much more efficient.

    To generate the sub location number where it doesn't exist, you can use the ROW_NUMBER() function.

    John

  • Thanks  John

    I cant use GUID as i need to link the merge column (key) from risk table to claims table.

    Never thought of it , let me try it now

    Silly me. Done.. Thanks very much

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

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