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 using data from another database

Author  Topic 

intergalacticplanetary
Starting Member

12 Posts

Posted - 2007-01-25 : 23:53:17
hi, i'm trying to create a table and populate it with data from another database residing on the same server. i've done this on oracle using tables within the same database and am just making a first effort with the added twist of a different database. this is what i've been doing so far...

CREATE TABLE facility_dimension
(
fac_id INT IDENTITY(1,1),
tri_fac_id CHAR(17),
fac_name VARCHAR(100),
street VARCHAR(100),
city VARCHAR(100),
county VARCHAR(50),
state VARCHAR(4),
longitude REAL,
latitude REAL,
PRIMARY KEY(fac_id)
)
SELECT tri_facility_id, facility_name, street_address,
city_name, county_name, state_abbr, fac_latitude,
fac_longitude
FROM TRI_2004.form_1;

....where TRI_2004 is the other database and form_1 is the table. the result is creation of the new table and then the output of the secondary query. i'm assuming this can even be done but if it can't that would be helpful to know as well. thanks in advance!

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-01-25 : 23:57:44
[code]select * into facility_dimension from TRI_2004.form_1[/code]


KH

Go to Top of Page

intergalacticplanetary
Starting Member

12 Posts

Posted - 2007-01-26 : 00:07:19
thanks KH!
Go to Top of Page
   

- Advertisement -