SQLTeam.com | Weblogs | Forums

How to correct this code


#1

hello

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


#2

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


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

:sniped: