Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How can i give the restrictions for the data entry, if i
wish to enter only I ,II, III, IV in the grade actegory of
student table?

Answers were Sorted based on User's Feedback



How can i give the restrictions for the data entry, if i wish to enter only I ,II, III, IV in the ..

Answer / soorai ganesh

If u Use SQLSERVER 2005. This will helpful to you


CREATE RULE myRule AS @strGrade IN('I','II','III','IV')
GO
CREATE TABLE myTable
(
empID INT,
empName VARCHAR(50),
empGrade VARCHAR(3),
empSalary NUMERIC(9,2)
);
GO
sp_bindrule myRule, 'myTable.empGrade';
GO


INSERT INTO myTable VALUES(1,'Ganesh','I',59000) -- Valid
INSERT INTO myTable VALUES(1,'Ganesh','II',89000) -- Valid
INSERT INTO myTable VALUES(1,'Ganesh','III',99000) -- Valid
INSERT INTO myTable VALUES(1,'Ganesh','IV',259000) -- Valid
INSERT INTO myTable VALUES(1,'Ganesh','V',259000) --
Invalid

Is This Answer Correct ?    12 Yes 0 No

How can i give the restrictions for the data entry, if i wish to enter only I ,II, III, IV in the ..

Answer / pervej

use constraint or rules that will helps u in this query
we can also use cursor for this for insert

Is This Answer Correct ?    0 Yes 0 No

How can i give the restrictions for the data entry, if i wish to enter only I ,II, III, IV in the ..

Answer / mohan

create table #test (sno int check(sno in(1,2,3)))

successfull statement:
insert into #test values(3)

failure statement :

insert into #test values(4)
error message:
INSERT statement conflicted with COLUMN CHECK
constraint 'CK__#test__sno__68E599B5'. The conflict
occurred in database 'tempdb',
table '#test________________________________________________
____________________________________________________________
___00000000D7E0', column 'sno'.
The statement has been terminated.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

Explain about system stored procedure?

0 Answers  


Can you give me some DBCC command options?(Database consistency check) - DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.and DBCC CHECKALLOC - To check that all pages in a db are correctly allocated. DBCC SQLPERF - It gives report on current usage of transaction log in percentage. DBCC CHECKFILEGROUP - Checks all tables file group for any damage.

0 Answers   iSoft,


How to find out the list schema name and table name for the database?

0 Answers  


What is "scheduled jobs" or "scheduled tasks"?

0 Answers  


What is a data source or ds? : sql server analysis services, ssas

0 Answers  


what is the system function to get the current user's user id? : Sql server database administration

0 Answers  


What is nolock hint in sql server 2008

0 Answers   HCL,


How to manipulate data from one table to another table ?

0 Answers   MCN Solutions,


What is the parse query button used for?

0 Answers  


How to round a numeric value to a specific precision?

0 Answers  


hi, how to link a text file and a .rpt file in my tables of sql server and to retrieve those records for further use. reply me as soon as possible.

0 Answers  


Write a stored procedure for emplpoyee and department table to get DeptName which having no employee. Table Structure- Emp-Emp_Id,Emp_Name,Dept_id Dept-Dept_Id,Dept_Name

7 Answers   TCS,


Categories