How to access data from two different tables in SQL Server 2005?


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’.

Advertisements

Author: Imran Akram

A .NET/SharePoint Consultant and a political enthusiast who believes in putting the feet of the elected and/or unelected officials to fire in order to get good governance.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s