I need to update a bigint value in a database with a concatenation of two strings. SQL does not like this. DailyArchive.LogicalAccount is a bigint, @padding and a.AccountNumber are varchars.
Update dbo.DailyArchive
SET DailyArchive.LogicalAccount = CONCAT(@padding, a.AccountNumber)
FROM @_AccountList a
JOIN dbo.DailyArchive ON a.AccountNumber = DailyArchive.LogicalAccount
I receive the following error message:
Msg 8114, Level 16, State 5, Procedure updateNumbers_ArchiveDB, Line 15 Error converting data type varchar to bigint.
How I am executing the procedure:
declare @p1 dbo.AccountListType
insert into @p1 values(N'Account Number',N'Account Type')
insert into @p1 values(N'7463689',N'Basic')
insert into @p1 values(N'1317893',N'Premium')
insert into @p1 values(N'2806127',N'Basic')
exec updateNumbers_ArchiveDB
@_AccountList=@p1,
@padding=N'111',
@proc_dateStart='2008-01-04 11:24:46',
@proc_dateEnd='2008-01-04 11:24:46'
select CONCAT(@padding, a.AccountNumber) FROM @_AccountList a JOIN dbo.DailyArchive ON a.AccountNumber = DailyArchive.LogicalAccount- do you see any that contain non-number characters? - Dave.Gugginsert into @p1 values(N'Account Number',N'Account Type'), So you are trying to convert('111' + 'Account Number')to a BIGINT. Remove this insert, and only insert valid data to your table and you should be fine. - GarethD