Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Creating a Table by combining two exisisting ones

Author  Topic 

Noe
Starting Member

3 Posts

Posted - 2012-10-23 : 11:53:23
Hi,

I need to create a new table.

The "New Table" is the combination of the "employee" and "Personnel" tables where the Personnel Table.

When combining the tables, I need to keep the information from the "Personnel" Table and add the missing fields or records not found on the "Personnel" table.

A big issue is that the "Employee" Table has the name of the employee in one field while the "Personnel" table has it broken down into 3 fields.

Could you please help me?

Thank you, Noe

Please see below the two tables, their fields and the Table I need to get from their combination:

Employee.................Personnel...............New Table

EmployeeNumber......EmployeeNumber.....EmployeeNumber
EmployeeName.........LastName...............LastName
Title........................FirstName..............FirstName
BuildingCode............MiddleInitial...........MiddleInitial
District....................Job Title................Job Title
..............................Location Code.........Location Code
..............................District..................District

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-10-23 : 12:07:04
I don't see any difference between the Personnel table and the new table.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

Noe
Starting Member

3 Posts

Posted - 2012-10-23 : 13:15:06
Jim, The fields look similar but the tables do not contain the same records. I left out the fields I do not need.

The name of the employee in one table is contained in one field while on the other table the name of theemployee is broken down into 3 fields(name, middle initial, and last name).

I am trying add the records not found in the "Personnel" table together with those ones in the personnel table into a new table.

One issue is how to break the employee name into three fields.

Originally posted by jimf

I don't see any difference between the Personnel table and the new table.

Jim
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2012-10-23 : 14:11:36
Breaking names apart is a notoriously difficult thing to do. As examples:
"David Henry Thoreau" simple enough; First Middle and Last
"Ludwig von Beethoven" not so simple; First and Last
"John Smith Senior" Actually a last name or a designator?

=================================================
We are far more concerned about the desecration of the flag than we are about the desecration of our land. -Wendell Berry
Go to Top of Page

Noe
Starting Member

3 Posts

Posted - 2012-10-23 : 15:37:18
Bustaz, I do not mean any disrespect: I need help or guidance and you are not doing either one with your comment.
quote:
Originally posted by Bustaz Kool

Breaking names apart is a notoriously difficult thing to do. As examples:
"David Henry Thoreau" simple enough; First Middle and Last
"Ludwig von Beethoven" not so simple; First and Last
"John Smith Senior" Actually a last name or a designator?

=================================================
We are far more concerned about the desecration of the flag than we are about the desecration of our land. -Wendell Berry

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-23 : 18:27:04
quote:
Originally posted by Noe

Bustaz, I do not mean any disrespect: I need help or guidance and you are not doing either one with your comment.
quote:
Originally posted by Bustaz Kool

Breaking names apart is a notoriously difficult thing to do. As examples:
"David Henry Thoreau" simple enough; First Middle and Last
"Ludwig von Beethoven" not so simple; First and Last
"John Smith Senior" Actually a last name or a designator?

=================================================
We are far more concerned about the desecration of the flag than we are about the desecration of our land. -Wendell Berry




Nope he was telling various business cases you need to consider. There's no straight forward way to break the names unless you can guarantee the format (which 90 % of cases you cant)

Otherways you've group them based on their format and apply a different logic for each group

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -