I want to copy a
VIEW from one server to another. I could copy tables but I can't copy views. Is there a way to do so?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
migrated from stackoverflow.com Aug 7 '12 at 23:29
This question came from our site for professional and enthusiast programmers.
The easiest way if you just want to do a quick
The possible choices as a destination for the
Let's say you want to copy a view from database DB1 to database DB2 The script generated using Script View as -> CREATE to -> starts with
When you execute it, it's executed against the source database, so you have to change this to
Also note that you have to have all the tables that the view references in DB2. Otherwise you'll get a message such as:
Invalid object name 'Schema.TableName'.
You can create the tables using the same steps as views.
Another option is to use a 3rd party tool that will create the view DDL and and script all dependent objects, so you don't have to worry about the tables.