Click here to Skip to main content
15,905,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I use any column value as default value of another column in a create table statement??

E.g.

create table test
(roll [int] not null,
srno [int] not null default roll,
name (varchar](50))
Posted
Comments
Tomas Takac 9-Apr-15 17:52pm    
You cannot do this, at least not in SQL Server. The default value must be a constant (literal) or system function call like GetDate(). Why do you need this really?
barneyman 9-Apr-15 21:16pm    
as Tomas says, no - you could do what you want in a trigger
Member 11312264 10-Apr-15 3:48am    
use trigger when insert a new row..

first insert value in roll.
then using trigger update the value of srno
John C Rayan 10-Apr-15 15:20pm    
It is not possible.
Member 11039257 8-May-15 7:22am    
It was not possible

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