![]() | |
#1
| ||||
| ||||
|
|
Part_num | Prt_name | Desc1 | Desc2 | -------------------------------------------------------------- PRT1 | PartA | abc | xyz | PRT2 | PartB | def | aaa | PRT3 | PartC | ghi | bbb | -------------------------------------------------------------- |
|
Cat_num | Cat_name | SDsc1 | SDsc2 | --------------------------------------------------------------- CAT1 | CatalogA | abc | xyz | CAT2 | CatalogB | def | aaa | CAT3 | CatalogC | ghi | bbb | --------------------------------------------------------------- |
|
Part_num | Prt_name | Desc1 | Desc2 | Cat_num | Cat_name | SDsc1 | SDsc2 | |
|
PRT1 | PartA | abc | xyz | PRT2 | PartB | def | aaa | PRT3 | PartC | ghi | bbb | | | | | CAT1 CatalogA | abc | xyz | | | | | CAT2 CatalogB | def | aaa | | | | | CAT3 CatalogC | ghi | bbb | ---------------------------------------------------------------------------------------------------------------------------- |
#2
| |||
| |||
|
|
Hi, I wanted to know if it is possible to do to append two tables into a third table. For example, consider these two tables Table 1 -------------------------------------------------------------- | Part_num | Prt_name | Desc1 | Desc2 | -------------------------------------------------------------- | PRT1 | PartA | abc | xyz | | PRT2 | PartB | def | aaa | | PRT3 | PartC | ghi | bbb | -------------------------------------------------------------- Table 2 --------------------------------------------------------------- | Cat_num | Cat_name | SDsc1 | SDsc2 | --------------------------------------------------------------- | CAT1 | CatalogA | abc | xyz | | CAT2 | CatalogB | def | aaa | | CAT3 | CatalogC | ghi | bbb | --------------------------------------------------------------- Now, I want to append them to get this : Table 3 ----------------------------------------------------------------------------------------------------------------------------- | Part_num | Prt_name | Desc1 | Desc2 | Cat_num | Cat_name | SDsc1 | SDsc2 | ----------------------------------------------------------------------------------------------------------------------------- | PRT1 | PartA | abc | xyz | | | PRT2 | PartB | def | aaa | | | PRT3 | PartC | ghi | bbb | | | | | | | CAT1 | CatalogA | abc | xyz | | | | | | CAT2 | CatalogB | def | aaa | | | | | | CAT3 | CatalogC | ghi | bbb | ---------------------------------------------------------------------------------------------------------------------------- The blanks in Table 3 are , well ,blank. Now can it be done or not? Awaiting your replies, Regards, Shwetabh |
#3
| |||
| |||
|
|
Table 3 -------------------------------------------------------------------------- --------------------------------------------------- | Part_num | Prt_name | Desc1 | Desc2 | Cat_num | Cat_name | SDsc1 | SDsc2 | -------------------------------------------------------------------------- --------------------------------------------------- | PRT1 | PartA | abc | xyz | | | PRT2 | PartB | def | aaa | | | PRT3 | PartC | ghi | bbb | | | | | | | CAT1 | CatalogA | abc | xyz | | | | | | CAT2 | CatalogB | def | aaa | | | | | | CAT3 | CatalogC | ghi | bbb | -------------------------------------------------------------------------- -------------------------------------------------- The blanks in Table 3 are , well ,blank. Now can it be done or not? |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Hi, it seems Table 3 got pretty messed up. So I will give the schema definations of the tables here: Table 1: CREATE TABLE TABLE1 ( PART_NUM varchar(10) primary key, PRT_NAME VARCHAR(10), DESC1 VARCHAR(20), DESC2 VARCHAR(20) ) Table 2: CREATE TABLE TABLE2 ( PART_NUM varchar(10) primary key, CAT_NUM VARCHAR(10), CAT_NAME VARCHAR(10), SDESC1 VARCHAR(20), SDESC2 VARCHAR(20) ) Now the resultant table should have the following schema: CREATE TABLE TABLE3 ( PART_NUM varchar(10) primary key, PRT_NAME VARCHAR(10), DESC1 VARCHAR(20), DESC2 VARCHAR(20), CAT_NUM VARCHAR(10), CAT_NAME VARCHAR(10), SDESC1 VARCHAR(20), SDESC2 VARCHAR(20) ) This schema will be created programmatically. Now my question is, if it is possible, how can I insert records from table1 and table2 in table3? I hope I have now made the things clearer. Awaiting your reply, Regards, Shwetabh |
#6
| |||
| |||
|
#7
| |||
| |||
|
#8
| |||
| |||
|
#9
| |||
| |||
|
|
Well I cant really do anything about the design for table2 because that is the way the client wants it to be. As far as table3 goes, I wanted to check the possiblility of appending the records of all the tables into a single table and check the performance and efficiency. I understand that table3 is a poor database design but the main motivation for doing this is to check the reaction of the application which will using such database. Also, till now, I have converted DBASE database into SQL database using OPENROWSET to import the data, I was wondering if the same database can be entered into a new table which can hold the data from all tables. Any ideas? |
#10
| |||
| |||
|
|
Shwetabh (shwetabhgoel (AT) gmail (DOT) com) writes: Well I cant really do anything about the design for table2 because that is the way the client wants it to be. As far as table3 goes, I wanted to check the possiblility of appending the records of all the tables into a single table and check the performance and efficiency. I understand that table3 is a poor database design but the main motivation for doing this is to check the reaction of the application which will using such database. Also, till now, I have converted DBASE database into SQL database using OPENROWSET to import the data, I was wondering if the same database can be entered into a new table which can hold the data from all tables. Any ideas? For it to be meaningful to merge table1 and table2 into one table, there must be some relation between the data. Is there any such relation? In your sample data PRT1 went with CAT1, but you did not indicate what rule said that these two should go together. If you don't know what you want, we will not know either. -- Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx |
![]() |
| Thread Tools | |
| Display Modes | |
| |