C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Using Constraints in Sql Server


Posted Date: 18 Jun 2008    Resource Type: Code Snippets    Category: SQL

Posted By: Kapil Dhawan       Member Level: Gold
Rating:     Points: 4



The list of common constraints is given below


  • Not Null

  • Unique

  • Check

  • Primary Key

  • foreign Key



NOT NULL



By default when we create a column in table, it can take null value. If we want that it should not take null then we use this constraints. The example for NOT NULL constraint is given below


CREATE TABLE TAB_EMPLOYEE
(
EMP_ID integer NOT NULL,
EMPNAME varchar (30) NOT NULL
)



UNIQUE



This constraint is responsible for having unique values in a column. Here is the code sample for UNIQUE constraint:


CREATE TABLE TAB_EMPLOYEE
(
EMP_ID integer UNIQUE,
EMPNAME varchar(30)
)




CHECK



CHECK constraint ensures that values are according to the conditions


CREATE TABLE TAB_EMPLOYEE
(
EMP_ID integer CHECK(EMP_ID > 0),
EMPNAME varchar(30)
)








Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Using constraints  .  Unique constraint  .  Not null constraint  .  Constraints in sql server  .  CHECK constraint  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to trim values in Sql Server
Previous Resource: String Concatenation in Sql Server
Return to Discussion Resource Index
Post New Resource
Category: SQL


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use