当我尝试执行我的 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)
)