I'm trying to do an Entity Framework walkthrough so I:
我正在尝试进行实体框架演练,所以我:
- downloaded SQL script here: http://www.learnentityframework.com
- in SQL Server Management Studio, I right-clicked Database, Create Database, named it
- right-clicked on the new database, New Query
- clicked on "Open File" and opened the script file: Create_ProgrammingEFDB1_SQLServer2008.sql
- clicked "! Execute"
- But the script (756K) has been running for 10 minutes now and still says "executing..."
这里下载了SQL脚本:http://www.learnentityframework.com
在SQL Server Management Studio中,我右键单击Database,Create Database,命名它
右键单击新数据库New Query
单击“打开文件”并打开脚本文件:Create_ProgrammingEFDB1_SQLServer2008.sql
点击“!执行”
但是脚本(756K)现在已经运行了10分钟,仍然说“执行......”
My questions are:
我的问题是:
- Is this the standard way to read in an SQL script into SQL Server?
- Is it supposed to take this long? This is how I would do it in MySQL/PHPMyAdmin it it might take a couple seconds, so I assume I'm not doing something right.
这是将SQL脚本读入SQL Server的标准方法吗?
它应该花这么久吗?这就是我在MySQL / PHPMyAdmin中的表现,它可能需要几秒钟,所以我假设我做的不对。
Here is the beginning of the script, I changed the file paths so they point to the right .mdf and .ldf files:
这是脚本的开头,我更改了文件路径,使它们指向正确的.mdf和.ldf文件:
****/
--PART ONE CREATE THE DATABASE. Note the file paths in the first few commands.
--Change them for your own computer.--
USE [master]
GO
/****** Object: Database [ProgrammingEFDB1] Script Date: 01/28/2009 10:17:44 ******/
CREATE DATABASE [ProgrammingEFDB1] ON PRIMARY
( NAME = N'ProgrammingEFDB1', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\ProgrammingEFDB1.mdf' , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'ProgrammingEFDB1_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\ProgrammingEFDB1_log.LDF' , MAXSIZE = UNLIMITED, FILEGROWTH = 10%)
GO
ALTER DATABASE [ProgrammingEFDB1] SET COMPATIBILITY_LEVEL = 90
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [ProgrammingEFDB1].[dbo].[sp_fulltext_database] @action = 'disable'
end
...
ANSWER:
I had already created a database with the same name so it was trying to create a database that was already there which made it hang for some reason. I deleted that database, reran the script and it completed successfully in 3 seconds.
我已经创建了一个具有相同名称的数据库,因此它试图创建一个已经存在的数据库,因为某些原因使其挂起。我删除了该数据库,重新编写脚本,并在3秒内成功完成。
2 个解决方案
#1
4
But the script (756K)
但剧本(756K)
Must be a lot more than just a CREATE DATABASE
in the script, so very hard to say when the script is doing.
必须不仅仅是脚本中的CREATE DATABASE,所以很难说脚本何时正在运行。
You can write progress reports from the script back to the client, or use SQL Profiler to see what commands are being executed.
您可以将脚本中的进度报告写回客户端,或使用SQL事件探查器查看正在执行的命令。
#2
5
I don't know what does your script do exactly in the next 754K
, but the lines you posted seem quite harmless.
我不知道你的脚本在接下来的754K中究竟做了什么,但是你发布的行似乎是无害的。
Try adding the following to your script:
尝试将以下内容添加到脚本中:
SET STATISTICS TIME ON
This will show queries execution times as they run, and it will help you to locate the problem more exactly.
这将在运行时显示查询执行时间,它将帮助您更准确地找到问题。
#1
4
But the script (756K)
但剧本(756K)
Must be a lot more than just a CREATE DATABASE
in the script, so very hard to say when the script is doing.
必须不仅仅是脚本中的CREATE DATABASE,所以很难说脚本何时正在运行。
You can write progress reports from the script back to the client, or use SQL Profiler to see what commands are being executed.
您可以将脚本中的进度报告写回客户端,或使用SQL事件探查器查看正在执行的命令。
#2
5
I don't know what does your script do exactly in the next 754K
, but the lines you posted seem quite harmless.
我不知道你的脚本在接下来的754K中究竟做了什么,但是你发布的行似乎是无害的。
Try adding the following to your script:
尝试将以下内容添加到脚本中:
SET STATISTICS TIME ON
This will show queries execution times as they run, and it will help you to locate the problem more exactly.
这将在运行时显示查询执行时间,它将帮助您更准确地找到问题。