使用 SELECT ... INTO 在 SQL Server 中创建表

发布于 2024-08-20 04:51:31 字数 193 浏览 1 评论 0原文

我正在使用像“SELECT Table1.* INTO Table2 FROM Table1”这样的查询在sqlserver数据库中创建一个表 这里表2创建成功,但当我再次触发此查询时,它没有显示我的数据库

,而是给出错误,表2已经创建,但我在数据库中看不到它,

我也在刷新我的数据库,

所以如果有人有解决方案,请帮助我..

i am creating a table in sqlserver database using query like "SELECT Table1.* INTO Table2 FROM Table1"
here Table2 created successfully but it is not showing my database

when i again fire this query than it gives error that Table2 is already created but i can't see this in my database

i am refreshing my database also

so please help me if anyone has solution..

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

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

发布评论

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

评论(2

攒一口袋星星 2024-08-27 04:51:31

@Ramesh 有正确的想法。在某些情况下(我认为如果您的用户处于 db_owner 角色?),SELECT INTO 表是在与您的登录关联的架构(SQL 2005+ 术语)中创建的。这可能类似于 YOURDOMAIN\username.Table2。如果您从同一个登录名中再次选择,它会正常工作,但其他用户很可能不会在您的架构中进行搜索。

如有疑问,请在 dbo 架构中显式创建表:

SELECT Table1.*
INTO dbo.Table2
FROM Table1

@Ramesh has the right idea. In some situations (I think if your user is in the db_owner role?), SELECT INTO tables are created in the schema (the SQL 2005+ terminology) associated with your login. This may be something like YOURDOMAIN\username.Table2. If you go to select again from the same login, it will work fine, but chances are that other users will not be searching in your schema.

When in doubt, explicitly create the table in the dbo schema:

SELECT Table1.*
INTO dbo.Table2
FROM Table1
戏舞 2024-08-27 04:51:31

您是否尝试过使用用户名.Table1,例如

  dbo.table

为任何数据库对象附加用户名非常重要,它强制用户选择他有权查看的对象

have you tried with the username.Table1, like

  dbo.table

Its very important to append the username for any db object, it enforces the user to select the objects which he got permission to view

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