Click here to Skip to main content
15,914,225 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Please give an SQL trigger which set user defined value as default.
e.g.
create table Student
(srNo int IDENTITY(1,1) not null,
RollNo int not null default <srno> -- This column will contains <srno> as default if user doesn't provide
StudentName varchar(50) not null)
Posted
Comments
ZurdoDev 15-Apr-15 15:57pm    
You don't need a trigger for a default. What exactly is your question?
RTK The Limited Edition 15-Apr-15 16:37pm    
create table Student
(srNo int IDENTITY(1,1) not null,
RollNo int not null default as srNo-- This column will contains as default if user doesn't provide any. Here I need 'srNo' as default for 'RollNo' column.
StudentName varchar(50) not null)
ZurdoDev 15-Apr-15 16:38pm    
Oh, thank you for clearing it up by repeating yourself verbatim.

1 solution

interview question or homework?

i *think* what you're after is an Insert Trigger[^], because that RollNo is not an identity column, and presumably is different per student (tho' that's me reaching, because your question is poor)

Examples of use[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900