SQL Server 2008:复制表结构和架构
感谢您抽出时间。我编辑了脚本并运行它,但仍然得到这个名称: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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果没有任何句点,硬括号表示表名称 - 它包括“dbo”。在您的示例中作为表名称的一部分。
如果您希望在 dbo 模式中创建表:
同样,如果您希望在 srp 模式中创建表:
表名没有任何异常字符,因此无需使用硬括号...
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:
Likewise, if you want the table created in the srp schema:
The table name doesn't have any unusual characters, so there's no need to use hard brackets...
您可以下载 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.