我有一个.sql脚本,我想从中构建一个数据库。如何在sqlcmd中执行此操作?我知道它就像:
CREATE DATABASE dbName
GO
但是如何指定.sql脚本和位置来构建数据库?
答案 0 :(得分:12)
使用@Jeremiah Peschka's answer为sqlcmd
实用程序提供要执行的脚本。
对于新创建的数据库的位置,可以将其指定为CREATE DATABASE
命令的一部分:
CREATE DATABASE dbName
ON (
NAME = dbName_dat,
FILENAME = 'D:\path\to\dbName.mdf'
)
LOG ON (
NAME = dbName_log,
FILENAME = 'D:\path\to\dbName.ldf'
)
从链接文章中可以看出,您也可以指定其他属性,例如初始大小,最大大小等。
答案 1 :(得分:8)
sqlcmd -i C:\path\to\file.sql
SQL Server books online可以找到更多选项。
答案 2 :(得分:3)
这很简单。只需输入以下命令即可运行sqlcmd:
sqlcmd -U sa -P password
然后输入:
CREATE DATABASE MYDB
GO
这将创建数据库。然后输入“退出”退出。
答案 3 :(得分:0)
使用这个: sqlcmd -i“c:\ my scripts \ my script.sql”
请参阅sqlcmd description at MS了解其他选项
答案 4 :(得分:0)
没有文件:
window.onload = function ()
{
"use strict"
var myBee = document.getElementById('bee');
var myBat = document.getElementById('bat');
var mySpider = document.getElementById('spider');
var myFlower = document.getElementById('flower');
var flowerPetal = document.getElementById('flowerPetal');
var petalButton = document.getElementById('petalBut');
var flowerLeaves = document.getElementById('flowerLeaves');
var leafButton = document.getElementById('leafBut');
var flowerFruit = document.getElementById('flowerFruit');
var fruitBut = document.getElementById('fruitBut');
var flowerStem = document.getElementById('flowerStem');
var stemBut = document.getElementById('stemBut');
var flowerSeeds = document.getElementById('flowerSeeds');
var seedBut = document.getElementById('seedBut');
var flowerRoots = document.getElementById('flowerRoots');
var rootBut = document.getElementById('rootBut');
var mySnail = document.getElementById('snail');
var myButter = document.getElementById('butterfly');
var textSpeech = document.getElementById('textSpeech');
var textSpeech1 = document.getElementById('textSpeech1');
var textSpeech2 = document.getElementById('textSpeech2');
var textSpeech3 = document.getElementById('textSpeech3');
var textSpeech4 = document.getElementById('textSpeech4');
var textSpeech5 = document.getElementById('textSpeech5');
var textSpeech6 = document.getElementById('textSpeech6');
var textSpeech7 = document.getElementById('textSpeech7');
var flowerClick = document.getElementById('clickFlower');
var flowerInfo = document.getElementById('flowerInfo');
TweenMax.to(myBee, 0, {
opacity: 0
});
TweenMax.to(myFlower, 0, {
opacity: 0
});
TweenMax.to(flowerPetal, 0, {
opacity: 0
});
TweenMax.to(petalButton, 0, {
opacity: 0
});
TweenMax.to(flowerLeaves, 0, {
opacity: 0
});
TweenMax.to(leafButton, 0, {
opacity: 0
});
TweenMax.to(flowerFruit, 0, {
opacity: 0
});
TweenMax.to(fruitBut, 0, {
opacity: 0
});
TweenMax.to(flowerStem, 0, {
opacity: 0
});
TweenMax.to(stemBut, 0, {
opacity: 0
});
TweenMax.to(flowerSeeds, 0, {
opacity: 0
});
TweenMax.to(seedBut, 0, {
opacity: 0
});
TweenMax.to(flowerRoots, 0, {
opacity: 0
});
TweenMax.to(rootBut, 0, {
opacity: 0
});
TweenMax.to(myBat, 0, {
opacity: 0
});
TweenMax.to(myButter, 0, {
opacity: 0
});
TweenMax.to(textSpeech, 0, {
opacity: 0
});
TweenMax.to(textSpeech1, 0, {
opacity: 0
});
TweenMax.to(textSpeech2, 0, {
opacity: 0
});
TweenMax.to(textSpeech3, 0, {
opacity: 0
});
TweenMax.to(textSpeech4, 0, {
opacity: 0
});
TweenMax.to(textSpeech5, 0, {
opacity: 0
});
TweenMax.to(textSpeech6, 0, {
opacity: 0
});
TweenMax.to(textSpeech7, 0, {
opacity: 0
});
TweenMax.to(flowerClick, 0, {
opacity: 0
});
TweenMax.to(mySnail, 0, {
opacity: 0
});
TweenMax.from(mySpider, 4, {
y: -100
});
TweenMax.to(mySpider, 4, {
y: 0
});
TweenMax.from(flowerInfo, 4, {
y: -100
});
TweenMax.to(flowerInfo, 4, {
y: 0
});
mySpider.addEventListener("click", function () {
TweenMax.to(mySpider, 3, {
opacity: 0
});
TweenMax.to(flowerInfo, 3, {
opacity: 0
});
TweenMax.from(myFlower, 3, {
y: 800
});
TweenMax.to(myFlower, 3, {
y: -10,
opacity: 1
});
TweenMax.from(mySnail, 3, {
x: 300,
opacity: 1,
delay: 2
});
TweenMax.to(mySnail, 3, {
x: 20,
opacity: 1,
delay: 2
});
TweenMax.from(flowerClick, 3, {
opacity: 0,
delay: 3
});
TweenMax.to(flowerClick, 3, {
opacity: 1,
delay: 3
});
TweenMax.to(petalButton, 3, {
opacity: 1,
delay: 3.5,
x: 75
});
TweenMax.to(leafButton, 3, {
opacity: 1,
delay: 3.5,
x: 50
});
TweenMax.to(rootBut, 3, {
opacity: 1,
delay: 3.5,
x: 100
});
TweenMax.to(fruitBut, 3, {
opacity: 1,
delay: 3.5,
x: 100
});
TweenMax.to(seedBut, 3, {
opacity: 1,
delay: 3.5,
x: 30
});
TweenMax.to(stemBut, 3, {
opacity: 1,
delay: 3.5,
x: 40
});
});
petalButton.addEventListener("click", function () {
TweenMax.to(flowerPetal, 3, {
opacity: 1
});
});
};