I suggest using select ... into ... from ...
to create a new table from existing data in one step. For your string operations substring()
seems appropriate. Please try the following query:
select
projectnum,
allw,
budjet,
substring(projectnum, 1, 3)
+ '-'
+ substring(projectnum, 7, 3)
+ case
when len(projectnum) = 10
then '-' + substring(projectnum, len(projectnum) - 1, 1) end
as project_code
into
new_table
from
old_table
Read more on substring()
at the Microsoft Docs.