[英]Permission to DROP Tables in SQL Server (T-SQL)
When running the DROP command (T-SQL) below on the SQL server the following message appears: 在SQL Server上运行以下DROP命令(T-SQL)时,将显示以下消息:
Cannot drop the table '[dbo].[TABELA]', because it does not exist or you do not have permission.
无法删除表'[dbo]。[TABELA]',因为该表不存在或您没有权限。
Comand COMAND
EXEC sp_MSForEachTable 'DROP TABLE [?]'
However, when I run another T-SQL command or a basic DROP Table, the above error message is not displayed, and the command is executed correctly. 但是,当我运行另一个T-SQL命令或基本的DROP表时,不会显示以上错误消息,并且该命令已正确执行。
DROP TABLE TABELA
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT all'
Both of the above commands work, what is the reason for the EXEC sp_MSForEachTable 'DROP TABLE [?]'
Need a permission? 以上两个命令均有效,
EXEC sp_MSForEachTable 'DROP TABLE [?]'
需要权限的原因是什么? and how to give this permission? 以及如何授予此权限?
Try without the brackets. 尝试不带括号。 They seem to make the engine believe you want to drop a table named
[dbo].[tablea]
as sp_MSForEachTable
already quotes if necessary. 它们似乎使引擎相信您要删除名为
[dbo].[tablea]
因为sp_MSForEachTable
在必要时已经引用了。 And of course a table named [dbo].[tablea]
doesn't exist. 当然,不存在名为
[dbo].[tablea]
的表。
EXEC sp_MSForEachTable 'DROP TABLE ?'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.