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.
If you're looking for a reliable and error-free way to insert binary data into Acumatica, using the CAST operator in MS SQL is a much safer approach than modifying existing records in UploadFile or UploadFileRevision.
Need a custom Acumatica solution tailored to your business? Leave us a request, and let's discuss how we can streamline your development needs!