运行由在不同服务器上生成脚本生成的脚本会出错 [英] Running the Script, made by generate script on different server gives error

查看:53
本文介绍了运行由在不同服务器上生成脚本生成的脚本会出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是使用 generate script 选项生成的脚本.

the following is a script which was generated using generate script option.

向导说这可以用来在不同的服务器上复制、创建数据库

the wizard says that this can be used to copy, create db on different servers

既然如此,为什么会出现这个错误呢??

so its made for it, then why does this error occur.??

Msg 5170, Level 16, State 1, Line 2
Cannot create file 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SECOND\MSSQL\DATA\Script Me.mdf' because it already exists. Change the file path or the file name, and retry the operation.
Msg 1802, Level 16, State 4, Line 2

无法在 sysdatabes 中找到脚本我"的条目

could not lacate entry for "script me" in sysdatabes

为什么它试图在同一台服务器上创建,我的意思是为什么脚本是这样写的??

why does it try to create on the same server, i mean why the script is written like that??

USE [master]
GO
/****** Object:  Database [Script Me]    Script Date: 10/23/2010 12:38:57 ******/
CREATE DATABASE [Script Me] ON  PRIMARY 
( NAME = N'Script Me', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SECOND\MSSQL\DATA\Script Me.mdf' , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'Script Me_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SECOND\MSSQL\DATA\Script Me_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [Script Me] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [Script Me].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [Script Me] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [Script Me] SET ANSI_NULLS OFF
GO
ALTER DATABASE [Script Me] SET ANSI_PADDING OFF
GO
ALTER DATABASE [Script Me] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [Script Me] SET ARITHABORT OFF
GO
ALTER DATABASE [Script Me] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [Script Me] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [Script Me] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [Script Me] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [Script Me] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [Script Me] SET CURSOR_DEFAULT  GLOBAL
GO
ALTER DATABASE [Script Me] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [Script Me] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [Script Me] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [Script Me] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [Script Me] SET  DISABLE_BROKER
GO
ALTER DATABASE [Script Me] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [Script Me] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [Script Me] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [Script Me] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [Script Me] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [Script Me] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [Script Me] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [Script Me] SET  READ_WRITE
GO
ALTER DATABASE [Script Me] SET RECOVERY FULL
GO
ALTER DATABASE [Script Me] SET  MULTI_USER
GO
ALTER DATABASE [Script Me] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [Script Me] SET DB_CHAINING OFF
GO
EXEC sys.sp_db_vardecimal_storage_format N'Script Me', N'ON'
GO
USE [Script Me]
GO
/****** Object:  Table [dbo].[TableOne]    Script Date: 10/23/2010 12:38:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TableOne](
 [id] [nchar](10) NOT NULL,
 [name] [nchar](10) NULL,
 CONSTRAINT [PK_TableOne] PRIMARY KEY CLUSTERED 
(
 [id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

我在做什么

  • 从一台服务器创建数据库脚本
  • 尝试在其他地方运行它,以便在那里也创建相同的表
  • 推荐答案

    编写脚本是为了替换自身.任何更改都可以,但它们取决于您.您应该始终(无论您使用哪种工具来创建脚本)通读您的脚本以确保它执行您希望它执行的操作(以及您希望它执行的操作).

    The script is written to replace itself. Any changes are OK, but they are up to you. You should always (no matter which tool you use to create your scripts) read over your script to make sure it does what you want it to do (and where you want it to do).

    您应该修改脚本以将以下内容替换为您想要的内容:

    You should modify the script to replace the following things with something that you want:

    CREATE DATABASE [Script Me] ON  PRIMARY 
    ( NAME = N'Script Me', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SECOND\MSSQL\DATA\Script Me.mdf' , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
     LOG ON 
    ( NAME = N'Script Me_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SECOND\MSSQL\DATA\Script Me_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB ,     FILEGROWTH = 10%)
    GO
    

    在这里,您应该更改路径和文件名.路径由您决定,但文件名通常遵循以下命名:

    Here, you should change the path and the filenames. The path is up to you, but the filenames usually follow this naming:

    • 数据:{数据库名称}.mdf
    • 日志:{数据库名称}_log.ldf

    您还应该将 Script Me 更改为脚本文件中存在的新数据库名称.

    You should also change Script Me to your new database name everywhere it exists in the script file.

    这篇关于运行由在不同服务器上生成脚本生成的脚本会出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆