使用 SELECT ... INTO 在 SQL Server 中创建表
我正在使用像“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@Ramesh 有正确的想法。在某些情况下(我认为如果您的用户处于
db_owner
角色?),SELECT INTO
表是在与您的登录关联的架构(SQL 2005+ 术语)中创建的。这可能类似于YOURDOMAIN\username.Table2
。如果您从同一个登录名中再次选择,它会正常工作,但其他用户很可能不会在您的架构中进行搜索。如有疑问,请在 dbo 架构中显式创建表:
@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 likeYOURDOMAIN\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:您是否尝试过使用用户名.Table1,例如
为任何数据库对象附加用户名非常重要,它强制用户选择他有权查看的对象
have you tried with the username.Table1, like
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