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?
Answer Posted / 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 |
Post New Answer View All Answers
What are the different methods available under sqlcommand class to access the data?
How to stop a loop early with break statements in ms sql server?
How many files can a database contain in sql server?how many types of data files exists in sql server? How many of those files can exist for a single database?
what is a transaction? : Sql server database administration
What are the recovery models for a database?
What is the difference between a view and a stored procedure?
What is the difference between varchar and nvarchar datatypes?
Tell me extended events in sql server 2008?
How many columns can we include on clustered index ?
What is the maximum size of a dimension? : sql server analysis services, ssas
What are data files?
explain different levels of normalization? : Sql server database administration
Suppose you want to implement the one-to-one relationships while designing tables. How would you do it?
Explain what are sparse columns?
what are constraints? Explain different types of constraints? : Sql server database administration