SQLTeam.com | Weblogs | Forums

How to correct this code



i have the following code but there is an error in it.
can you help me please?
Auditnummer is an int datatype

update dbo.CQA_Auftrag
set Auditnummer_new= YEAR(GETDATE())+'_'+Auditnummer


Simple. You can't add an integer and a string. Convert the integers to strings (using CAST or CONVERT) first

update dbo.CQA_Auftrag
set Auditnummer_new = convert(varchar(10), YEAR(GETDATE()))+'_'
                    + convert(varchar(10), Auditnummer)