Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE UserRole (
- Id int NOT NULL IDENTITY (1, 1),
- [Name] nvarchar(50) NOT NULL,
- CONSTRAINT PK_UserRole PRIMARY KEY (Id)
- )
- GO
- SET IDENTITY_INSERT UserRole ON
- GO
- INSERT INTO UserRole (Id, [Name])
- VALUES
- (1, 'Admin'),
- (2, 'User')
- GO
- SET IDENTITY_INSERT UserRole OFF
- GO
- ALTER TABLE [USER]
- ADD RoleId int NULL
- GO
- UPDATE [USER]
- SET RoleId = 2
- GO
- ALTER TABLE [USER]
- ALTER COLUMN RoleId int NOT NULL
- GO
- ALTER TABLE dbo.[USER]
- ADD CONSTRAINT FK_USER_UserRole FOREIGN KEY (RoleId)
- REFERENCES dbo.UserRole (Id)
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement