简体   繁体   中英

SQL SERVER backup database into .sql file using script or cmd

I am trying to migrate from SQL SERVER 2012 to 2014 and found out I cannot use .bak files because of different versions. I know how to create a .sql back up file using the SSMS but I can't find a solution using a script or sqlcmd.

turns out I could use .bak files to restore databases. The problem was I'm trying to restore the file from a directory that SSMS is not authorized. Was a silly mistake. Sorry.

If you require to get the data in .sql files then the SQL Server's Generate Scripts wizard is the best option otherwise you can create .bak of your database and restore it on higher version.

在此处输入图片说明

Why can't you use SSMS?

Exporting to .sql file has been discussed in How to backup Sql Server to sql file?

Did you consider Linked Servers ? You can use 3 and 4 part names to access data from one server to another, for details see How can I connect to an external database from a sql statement or a stored procedure? . Another alternative to access data is trough OPENROWSET, that is also discussed above.

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