Curtis Long
asked on
Sql 2008 Table duplication
If I wanted to create a table and make the columns equal the data from another table, can i do this??
Example:
I have a table called plantname_foods_USA_INC_Fo odinfo
Under that table I have a column called contract_information_growe r
The data in that column is: grower 1
I want to create a table called plantname
a column called Farm
and data that equals the data from the contract_information_growe r column in the plantname_foods_USA_INC_Fo odinfo table.
Thanks!!
Example:
I have a table called plantname_foods_USA_INC_Fo
Under that table I have a column called contract_information_growe
The data in that column is: grower 1
I want to create a table called plantname
a column called Farm
and data that equals the data from the contract_information_growe
Thanks!!
The above will create the single-column table empty ... to create it with the actual data, remove the WHERE clause.
also, the above assumes that the table plantname doesn't exist yet.
ASKER
Will this create a "Live" link??
If the data in the first table changes will it reflect to the new table??
If the data in the first table changes will it reflect to the new table??
no, what you are talking about is a view ... do this:
create view plantname
as
select contract_information_growe r as Farm
from plantname_foods_USA_INC_Fo odinfo
create view plantname
as
select contract_information_growe
from plantname_foods_USA_INC_Fo
... then you can do this: select * from plantname
and it will reflect changes in the actual table plantname_foods_USA_INC_Fo odinfo
and it will reflect changes in the actual table plantname_foods_USA_INC_Fo
... and of course you can include additional columns (if you want) from the original table.
OR, if what you are looking for is all the distinct values from the original column (e.g. without repeats) then include the distinct keyword:
create view plantname
as
select distinct contract_information_growe r as Farm
from plantname_foods_USA_INC_Fo odinfo
OR, if what you are looking for is all the distinct values from the original column (e.g. without repeats) then include the distinct keyword:
create view plantname
as
select distinct contract_information_growe
from plantname_foods_USA_INC_Fo
ASKER
It will take a me a few to assimulate that info.
Thanks!!
Thanks!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
SWEET!! Found "Alias" :-)
That fixes EVERYTHING. :-)
Thanks SO much!!
That fixes EVERYTHING. :-)
Thanks SO much!!
into plantname
from plantname_foods_USA_INC_Fo
where 1 = 0