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
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 |
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 |
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 |
Explain datetime2 data type in sal server 2008?
What is the difference between views and stored procedures? Can we have input parameters for views?
What is the difference between WHERE AND IN? OR 1. SELECT * FROM EMPLOYEE WHERE EMPID=123 2. SELECT * FROM EMPLOYEE WHERE EMPID IN (123) WHAT IS THE DIFFERENCE?
What is the use of set nocount on/off statement?
How do you use DBCC statements to monitor various aspects of a SQL server installation?
Explain fundamentals of Data ware housing & OLAP?
Explain about thread and memory management process of SQL?
How do I find the sql server instance name?
Do you know what is raid and what are different types of raid configurations? : SQL Server Architecture
Explain different isolation levels?
How can I change procedure name in sql server?
What is sql injection and why is it a problem? : sql server security
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)