名爲「角色」當我嘗試執行我的TSQL代碼的對象,我得到異常:已經有一個在數據庫
Msg 2714, Level 16, State 6, Line 2
There is already an object named 'Role' in the database.
Msg 2714, Level 16, State 6, Line 2
There is already an object named 'User' in the database.
但我沒有任何數據庫。我需要建議。
代碼如下所示:
USE master
GO
CREATE DATABASE PortalDB
GO
CREATE TABLE [Role]
(
[ID] INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,
[Name] NVARCHAR(50) NOT NULL,
)
GO
CREATE TABLE [User]
(
[ID] INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,
[Name] NVARCHAR(50) NOT NULL,
[UserName] NVARCHAR(50) NOT NULL,
[Password] NVARCHAR (100) NOT NULL,
[Email] NVARCHAR (100) NOT NULL,
[RoleID] INT NOT NULL FOREIGN KEY REFERENCES [Role](ID)
)
我改變了表名,但仍然是一個例外。我嘗試了太多的話。 – fuat
我執行了 SELECT * FROM sys.objects Mssql服務器在sys.objects中創建了我所有的表名。什麼錯我不明白。 – fuat
嘗試了CREATE TABLE dbo。[user]仍然是一個例外。 – fuat