.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> Sql Server >> Post New Question Subscribe to Interview Questions

How you will create a CHECK Constraint when the table is already created

Posted By :Syed Shakeer Hussain     Posted Date :November 29, 2009    Points :10   Category :Sql Server 
ALTER TABLE table_name
ADD CHECK (P_Id>0)

You can also find related Interview Question to How you will create a CHECK Constraint when the table is already created  below: 

What command is used to create a table by copying the structure of another table?

  
CREATE TABLE .. AS SELECT command

Explanation :

To copy only the structure, the WHERE clause of the SELECT command should contain a FALSE statement as in the following.
CREATE TABLE NEWTABLE AS SELECT * FROM EXISTINGTABLE WHERE 1=2;
If the WHERE condition is true, then all the rows or rows satisfying the condition will be copied to the new table. (More...)

What is Check Constraint?

  
Check constraint specifies a condition that is enforced for each row of the table on which the constraint is defined. Once constraint is defined, insert or update to the data within the tables is checked against the defined constraint
(More...)

What is the difference between RULE and Check Constraint?

  
The major difference between rule and Check is reusability. Check constraint is associated with columns in a Table. So these can't be re-used. Rules are defined with in a database and can be applied to any number of columns. (More...)

Which command is used to create a table by copying the structure of another table?

  
CREATE TABLE .. AS SELECT command
Example:-
CREATE TABLE AS SELECT*FROM WHERE 1=2; (More...)

Would the select query below fetch any records?



create table #testvm (ID int)

select * from sysobjects where name = '#testvm'

drop table #testvm

  
No..

Since temp tables are created in tempdb, and use a random name, the query will not work.

If you used a query like this, you would see your table:

select * from tempdb..sysobjects where name like '#testvm%' (More...)

How do we create table from another table in sql?

  

CREATE TABLE new_table
AS (SELECT * FROM old_table);
(More...)

What are check constraint

  
? A CHECK constraint is used to limit the values that can be placed in a column.
? The check constraints are used to enforce domain integrity.
(More...)

Database should be created as a SINGLE_USER state Whenever you create a new Database. What should you do ?

  
1. Normally, when we create a new database, All the properties will be inherited from the Model database.

2. So, Just change the Model database's State to SINGLE_USER.

3. Now onwards, The new database will be created as SINGLE_USER state. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend