Home Forums SQL Server 2008 T-SQL (SS2K8) Most efficient way to get a single unique combined record for distributed information corresponding to same ID RE: Most efficient way to get a single unique combined record for distributed information corresponding to same ID

  • Thank you for the quick reply.

    I have already tried using this approach. It is based on the assumption that there will be only one value per column corresponding to a primary key.

    Suppose if I insert one more record in same table like this:

    insert into #temp(id,contact_number)

    select 1,'565-888-9654'

    Then select * from #temp will be interpreted as ID=1 has 2 contact numbers.

    Actual output in this case should be

    id,name,age,contact_number

    1,John,34,222-444-5555

    1,John,34,565-888-9654

    Aggregation will give me only 1 record.

    I know this is not the proper way of storing data but right now I am stuck with something like this.