Skip to content
Advertisement

Formatting the surrogate key based on other columns

I have a table in SQL Server

I want my registerNumber to be of type batch+branch+id
eg a row in student id:1, batch:17, branch:BIT then the registerNumber should be 17BIT1

I tried to do this by using a default value in create table but it does not allow me to reference the columns of the same table

edit

thank you for the answers I went with this

Advertisement

Answer

Just use a computed column:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement