Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8663367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:58:18+00:00 2026-06-12T16:58:18+00:00

I have an employee table with multiple entries for the same person. Using their

  • 0

I have an employee table with multiple entries for the same person.
Using their SIN number you are able to determine if they are the same person.

Example:

Id  Name    SIN
1   John Smith  1234
2   John Smith  1234
3   Jess Jones  4321

I want to be able to copy everyone in this table, into a new table.
I want to create a new column (UserKey [GUID]) that is unique to the user who is in the table multiple times.
I want to use this new UserKey [GUID] instead of the SIN number.

Example:
Id  Name        UserKey (Guid)
1   John Smith  1234DFKJ2328LJFD
2   John Smith  1234DFKJ2328LJFD
3   Jess Jones  9543SLDFJ28EKJFF

I have no idea on how to approach this query. Any help would be great.

I am using MS SQL Server 2008.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:58:19+00:00Added an answer on June 12, 2026 at 4:58 pm

    You can just create a temp table, mapping SIN to a new GUID. Then you can join the original table with the mapping table, and create the new table from that.

    # Create a table called #temp with the mappings SID => new GUID
    SELECT SIN, newid() UserKey INTO #temp FROM (SELECT DISTINCT SIN FROM Table1) a
    
    # ...and join that and the original table to a new table.
    SELECT id, name, userkey
    INTO NewTable
    FROM Table1 t1
    JOIN #temp t2
    ON t1.SIN = t2.SIN
    

    SQLFiddle here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with multiple date columns per employee: Emp 1, Date1, Date2,
I have Employee table and an Entity class for it, My task is such
I have a employee table, and a vacations table where each row represents a
I have an employee table, with the following data. For a particular manager, i
Suppose I have employee and department table, employee has foreign key departmentID that is
I have a table: Employee (employeeID) EmployeeRank (rankID, employeeID) Now I have another table
I have two table Employee and Salary table, salary consists Salary of employee in
I have this function: show_employee_table() -> do(qlc:q([B || B <- mnesia:table(employee)])). What it does
I have the following database design: Employee Table: Username, Name, DivisionCode Division Table: SapCode,
I have the following database design: Employee Table: Username, Name Quiz Table: QuizID, Title,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.