Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

CONSTRAINTS for USERS TABLE: NICKNAME, NAME, SURNAME, PASSWORD, EMAIL.

$
0
0

Hello,

I have a problem finding out solution for my problem. Problem is I am trying to create the Users table and what to add CONSTRAINTS for each column. 

1.  nickname - should be only capital letters, non capital letters  and numbers no symbols. 

2. firstname and lastname - should be only capital letters, non capital letters  no symbols or numbers. 

3. email - format should be %@%.% and it should include at least one letter or number between @ and . 

4. Password - should have at least one capital, non capital letter and number in it not symbols. I will try to add them later then I get better on SQL.

I am new in SQL/T-SQL so constructive criticism are welcome regarding the post. 

USE WebDB;
GO
CREATE TABLE Users.Users
(
	UsersID INT NOT NULL PRIMARY KEY,
	nickname VARCHAR(10) NOT NULL UNIQUE
		CONSTRAINT CK_Nickname CHECK ( nickname LIKE '[A-Z],[a-z],[0-9]' ),
	firstname VARCHAR(20) NOT NULL
		CONSTRAINT CK_firstname CHECK ( firstname LIKE '[A-Z],[a-z]' ),
	lastname VARCHAR(30) NOT NULL
		CONSTRAINT CK_lastname CHECK ( lastname LIKE '[A-Z],[a-z]' ),
	email NVARCHAR(255) NOT NULL UNIQUE
		CONSTRAINT CK_email CHECK ( email LIKE '%@%.%' ),
	UserPassWord NVARCHAR(20) NOT NULL

);



Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>