Is it possible to tell sql server to cast to a datatype and set the
field length to a variable.
e.g. :-
declare @flen int
set @flen = 10
select (cast somefield as char(@flen) newfield)
into newtable
from sometable
I have also tried :-
select (cast somefield as char(max(len(so mefield))) newfield)
into newtable
from sometable
When I try the above examples I get error in @flen; error in max
respectivly.
TIA
Simon
field length to a variable.
e.g. :-
declare @flen int
set @flen = 10
select (cast somefield as char(@flen) newfield)
into newtable
from sometable
I have also tried :-
select (cast somefield as char(max(len(so mefield))) newfield)
into newtable
from sometable
When I try the above examples I get error in @flen; error in max
respectivly.
TIA
Simon
Comment