SQL Phone Number Format

Опубликовано: 27 Май 2023
на канале: SQL Learning Resources: Dr. Cecelia Allison
3,613
21

SQL Phone Number Format

This video demonstrates how to create a SQL phone number format constraint using a phone number CHECK Constraint.

Learn SQL FREE ✍with a "Practice Database"!
   • Learn SQL Fast 🚀  

Data Science Career Training:
https://www.jaffainc.com/Entrepreneur...

Search "Top Job Listings"!
https://www.jaffainc.com/research-car...



▶️ QUERY EXAMPLES:

► CREATE A PHONE NUMBER CHECK CONSTRINT

CREATE TABLE Customers
(
CustomerID INTEGER Primary Key NOT NULL,
FirstName CHAR(50) NOT NULL,
LastName CHAR(50) NOT NULL,
PhoneNumber CHAR(20) CHECK (PhoneNumber LIKE '[0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]'),
CellNumber CHAR(20),
Address CHAR(50),
State CHAR(02),
City CHAR(30),
ZipCode INTEGER
);



► CREATE A PHONE NUMBER CHECK CONSTRINT ON THE EXISTING CUSTOMERS TABLE:

ALTER TABLE Customers
ADD CONSTRAINT ValidPhoneNumber
CHECK (CellNumber LIKE '[0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]');



► DELETE THE VALIDPHONENUMBER CONSTRAINT:

ALTER TABLE Customers
DROP CONSTRAINT ValidPhoneNumber;



► VIEW CONSTRAINTS ON THE CUSTOMERS TABLE:

EXEC sp_helpconstraint Customers



🚀 COOL SQL TIPS AND TRICKS!

VIEW All the Tables & Columns in the Database:
   • Show All Tables in Database | Learn S...  

ADD Conditional Logic to Queries:
   • SQL Case Statement | Learn SQL Fast 🚀  

FIX Common SQL Errors:
   • SQL Server Errors | Fixes and More ⭐  

COPY Data from One Table to Another:
   • How to Copy Data from One Table to An...  

COMBINE Multiple Strings:
   • Handy SQL Tips & Techniques! 🚀  

CREATE an SQL Phone Number Format:
   • SQL Phone Number Format | Learn SQL F...  

FORMAT Dates in an SQL Query:
   • Format Date in SQL Query | Learn SQL ...  

ALTER Tables in SQL:
   • Alter Tables in SQL | Learn SQL Fast 🚀  

ADD Table Constraints to a Table:
   • Add Constraints | Learn SQL Fast 🚀  

Query Multiple Tables Simultaneously:
   • INNER Join SQL | Learn SQL Fast 🚀  

Get Started Using SQL Server:
   • SQL Server | Get Started!  




BOOST YOUR CAREER GROWTH!

🔹 Train for a Career in Data:
https://www.jaffainc.com/Entrepreneur...

🔹 Earn "SQL 🏅 Certifications & CEUs" (Continuing Education Units)
https://www.jaffainc.com/SQLCertifica...


#database #data #sql #sqlqueries #sqlforbeginners #sqltutorial #sqlcertificate #learnsql #sqltraining #sqlserver #relational #sqltips #sqlsyntax #sqlservertutorial #learnprogramming #datascience #databaseskills #dataanalysis #databasecertification #sqlcourse #practice #sqlpractice #sqlservertutorial #sqlservermanagementstudio #sqlskills