-1

实际上,如何在数据库 SQL Server 2008 中使用查询创建新表

尝试执行查询时出错

这是我的代码

 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FilesStore]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
 drop table [dbo].[FilesStore]
 GO

 CREATE TABLE [dbo].[FilesStore] (
     [FileId] [int] IDENTITY (1, 1) NOT NULL ,
     [OriginalPath] [varchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
     [FileData] [image] NOT NULL 
 ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 GO

我收到此错误消息

不支持 DROP TABLE SQL 构造或语句 不支持
CREATE TABLE SQL 构造或语句。

任何人请帮助我

谢谢

4

2 回答 2

0

我试过这个脚本并且工作得很好。

你有 db_owner 角色吗?

于 2012-08-16T16:43:01.597 回答
0

Permissions! You do not have sufficient permissions to execute CREATE or DROP. Check the Security database role for your user on your database.

As DROP is not a grantable permission, people who can drop a table are:

  • The dbo
  • The owner of the schema
  • The owner of the table (usually the schema owner but it can be changed to someone else)
  • members of the db_ddladmin fixed database role members of the db_owner fixed
  • database role members of the sysadmin fixed server role
  • grantees of the CONTROL permission on the table or permissions that imply control on the table
  • grantees of the ALTER permission on the schema or permissions that imply alter on the schema.

Update:
How to add yourself as db_owner for your database?

On the SQL Server Management Studio, go to the Security > Logins node for your SERVER in the tree. Locate the creds that you use to connect to SQL Server, right-click Properties.
Click on User Mapping, check your database checkbox in the list on the right and check the db_owner checkbox in the bottom. Click OK.
Try the query again.

于 2012-08-16T16:48:41.887 回答