本文介绍了如何使用sqlcmd创建数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 .sql 脚本,我想用它构建一个数据库.如何在 sqlcmd 中做到这一点?我知道这就像:
I have a .sql script and I want to build a database from it. How to do it in sqlcmd? I know it's like:
CREATE DATABASE dbName GO但是如何指定 .sql 脚本和位置来构建数据库?
But how to specify the .sql script and location to build the database?
推荐答案使用 @Jeremiah Peschka's answer 提供sqlcmd 实用程序以及要执行的脚本.
Use @Jeremiah Peschka's answer to supply the sqlcmd utility with the script to execute.
至于新创建的数据库的位置,可以指定为创建数据库命令:
As for the location for the newly created database, it can be specified as part of the CREATE DATABASE command:
CREATE DATABASE dbName ON ( NAME = dbName_dat, FILENAME = 'D:\path\to\dbName.mdf' ) LOG ON ( NAME = dbName_log, FILENAME = 'D:\path\to\dbName.ldf' )正如您从链接的文章中看到的,您还可以指定其他属性,例如初始大小、最大大小等.
As you can see from the linked article, you can specify other properties as well, like initial size, maximum size etc.
更多推荐
如何使用sqlcmd创建数据库
发布评论