SQL Server Query to Insert Null Values into a Table
CREATE TABLE CUSTOMERS ( CID INT PRIMARY KEY,
CNAME VARCHAR(15), GENDER VARCHAR(3),
SAL DECIMAL(10,2), UNIQUE(CNAME));
CNAME VARCHAR(15), GENDER VARCHAR(3),
SAL DECIMAL(10,2), UNIQUE(CNAME));
INSERT CUSTOMERS VALUES(1,'JAN','M',10000.15);
--Inserting Blank value and a Null Value into a Column with UNIQUE Constraint.
INSERT CUSTOMERS VALUES(2,'','F',20000.25);
INSERT CUSTOMERS VALUES(3,NULL,'F',30000.35);
SELECT*FROM
CUSTOMERS;
DROP TABLE CUSTOMERS;
NOTES :
-- Primary Key
column will not Allow duplicate and Null Values.
-- Primary Key
is a Table and Column level Constraint.
-- UNIQUE
Constraint column will not allow duplicates but allows Null Values.
-- UNIQUE is a
Table and Column level Constraint.
--------------------------------------------------------------------------------------------------------
No comments:
Post a Comment
Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.