I am in trouble please help.
After searching for my question I decided to post here.
Look at my code below and tell me if I can set default value as a function.
What I want to do is to show first three characters of my first column's data which is Product_Name
.
For example my first column has a name Xperia
and and I want its first three characters to be shown in the last column which I have created using alter code.
I hope you understand what I say.
Xperia ----> Xpe
Code is :
alter table dummy
add new_col varchar(250) default substring(first_column, 1, 3)
returns an error:
Msg 128, Level 15, State 1, Line 2
The name "first_column" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
However I can set getdate()
function as a default value.
Thanks
Product_Name
? – Tony