--Constraint's in Sql Server 2005-2008
--Not Null and Default
CREATE TABLE user1
(
sno INT IDENTITY(1, 1),
id INT NOT NULL,-- means the value cannot be null/blank or we can say mandatory feild needs to be filled
name1 VARCHAR(20),
orderdate DATETIME DEFAULT Getdate(),--if entered as blank by default it will take current date
app_status VARCHAR(10) DEFAULT 'pending'--if status left blank by default for each id it will be pending
)
INSERT INTO user1
VALUES (101,
'john',
'2010-09-15',
'approved')
INSERT INTO user1
(id,
name1,
app_status)
VALUES (103,
'will',
'approved')
INSERT INTO user1
(id,
name1)
VALUES (104,
'sam')
SELECT * FROM user1
Listen to Your Daily Tune's
Sunday, September 19, 2010
Constraint's in Sql Server 2005-2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment