SQL Server 2008:复制表结构和架构

发布于 2024-10-05 14:13:54 字数 484 浏览 0 评论 0原文

感谢您抽出时间。我编辑了脚本并运行它,但仍然得到这个名称:srp.dbo.gstDataCutover。我以前可以使用 MSSQL2005 轻松地做到这一点。我们最近升级到 2008。我不记得用其他方式做过...

嗨,

我正在尝试将表结构(列、数据类型、模式)复制到新表中以具有相同的模式和结构,使用下面的sql代码。

SELECT     dbo.gstData.*
INTO            [dbo.gstDataCutover]
FROM         dbo.gstData
WHERE      dbo.gstData.gstID < 1

我的问题是,当我运行此脚本时,新表 dbo.gstDataCutover 被命名为“dbo.gstDataCutover”,但架构默认为系统架构(“srp”),实际上是>srp.[dbo.gstDataCutover]。

我想复制结构和架构。

谢谢!

thanks for your time. i edited my script, ran it, and still got this name: srp.dbo.gstDataCutover. i used to be able to do this easily with MSSQL2005. we've recently upgraded to 2008. and i dont remember doing it any other way...

Hi,

I'm trying to copy a table structure (columns, datatypes, schema) into a new table to have the same schema and structure, using the sql code below.

SELECT     dbo.gstData.*
INTO            [dbo.gstDataCutover]
FROM         dbo.gstData
WHERE      dbo.gstData.gstID < 1

My problem is, when i run this script the new table dbo.gstDataCutover is named as "dbo.gstDataCutover" but the schema is defaulted to the system schema ("srp"), which is actually srp.[dbo.gstDataCutover].

I want to copy both the structure and the schema.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

念﹏祤嫣 2024-10-12 14:13:54

如果没有任何句点,硬括号表示表名称 - 它包括“dbo”。在您的示例中作为表名称的一部分。

如果您希望在 dbo 模式中创建表:

SELECT t.*
  INTO dbo.gstDataCutover
  FROM dbo.gstData t
 WHERE t.gstID < 1

同样,如果您希望在 srp 模式中创建表:

SELECT t.*
  INTO srp.gstDataCutover
  FROM dbo.gstData t
 WHERE t.gstID < 1

表名没有任何异常字符,因此无需使用硬括号...

Without any periods, the hard brackets indicate table name -- it's including the "dbo." in your example as part of the table name.

If you want the table created in the dbo schema:

SELECT t.*
  INTO dbo.gstDataCutover
  FROM dbo.gstData t
 WHERE t.gstID < 1

Likewise, if you want the table created in the srp schema:

SELECT t.*
  INTO srp.gstDataCutover
  FROM dbo.gstData t
 WHERE t.gstID < 1

The table name doesn't have any unusual characters, so there's no need to use hard brackets...

怎樣才叫好 2024-10-12 14:13:54

您可以下载 Visual Studio 的社区版,它具有比较架构和数据的功能。它将列出差异并允许您选择一组更改,并为其生成更新脚本。

输入图片此处描述

You can download the community edition of Visual Studio, which has features for comparing schemas as well as data. It will list the differences and allows you to select a set of changes, for which it will generate an update-script.

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文