How to insert VARBINARY data in MS SQL for Acumatica

Hello everybody,

sometime it is needed to insert some binary information in one or another table inside of Acumatica. Quite often developers just modify existing record in table UploadFile or UploadFileRevision.

But I don't like such approach, as it is prone to errors and potentially can harm some of your existing data. That's why I propose to use cast operator of MS SQL. Take a look at following example:

insert into UploadFileRevision(CompanyID, FileID, FileRevisionID, Data, Size, CreatedByID, CreatedDateTime, CompanyMask) values
								(2, '35b15ad7-b5c3-4a19-aa77-3a24c046d689', 1, 
													CAST('wahid' AS VARBINARY(MAX)),
													4, 
													'B5344897-037E-4D58-B5C3-1BDFD0F47BF9',
													'2016-06-08 08:53:50.937',
																	0xAA)

Take notice of 

CAST('wahid' AS VARBINARY(MAX)),

line. It will insert into local dev instance database varbinary representation of wahid. 

No Comments

Add a Comment