How to access data from two different tables in SQL Server 2005?
July 21, 2008
Leave a comment
howdy,
well I was having a problem where I needed to populate the table of my SQL Express 2005 database from another table in another database. So I wrote the query in the following fashion:
INSERT INTO debtdb.SchemaName.TableName (column1, column2….)
SELECT Column1, column2…
FROM dbName.SchemaName.TableName
my sample query was this
Insert into db2.dbo.tblNationality(NationalityName)
Select
Name FROM db1.dbo.tblNationality
what it does is that it takes the data from the database called db1 and inserts it into another database –on the same server, called ‘db2′.

