简体   繁体   中英

Transfer data to a newly created view from a table in another database in ssms

I have two different databases. Let's say ' DbOne ' and ' DbTwo '.

Is there any way to do the followings?

  1. Create a view in DbOne
  2. Transfer data in a particular table from DbTwo to the newly created view in DbOne.

I am using SSMS and still figuring out the appropriate query..

Please give me any advice.

You need INSERT / SELECT statement - eg.

INSERT INTO DbOne..NewView
SELECT * FROM DbTwo..SourceTable

However, depending on the structure of both tables, you may need to specify the particular columns in the SELECT statement, to match the structure of the target table. (By the way, note that data is always going into a TABLE - not a VIEW. You can do an INSERT into a VIEW, but only under certain conditions)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM