deemytch

deemytch

TDS: Inserting binary into VARBINARY won't work

I try to insert binary string into VARBINARY field in MSSQL table.

If my string have symbols 0-10 TDS recognizes that that is a binary and insertion works.

Otherwise it fails.

This one works:
iex(2)> TdsTest.TestRepo.insert(%TdsTest.Rawdata{ID: UUID.uuid4(), FVarBin: <<1,2,3,4,5>>})
11:24:02.963 [debug] QUERY OK source=“Rawdata” db=10.5ms queue=2.0ms idle=228.8ms
INSERT INTO [dbo].[Rawdata] ([ID],[FVarBin]) VALUES (@1, @2) [“759b8945-d13b-4190-845f-91f343735bc2”, <<1, 2, 3, 4, 5>>]

But that won’t:

iex(3)> TdsTest.TestRepo.insert(%TdsTest.Rawdata{ID: UUID.uuid4(), FVarBin: <<32,33,34,35>>})
11:24:15.535 [debug] QUERY ERROR source=“Rawdata” db=0.0ms queue=1.4ms idle=812.4ms
INSERT INTO [dbo].[Rawdata] ([ID],[FVarBin]) VALUES (@1, @2) [“7fd4d3de-b0c9-4a79-b3f1-6f9c31e1c8f4”, " !"#"]

That’s coming from database: “** (Tds.Error) Line 1 (Error 257): Implicit conversion from data type nvarchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.”

FVarBin is VARBINARY(MAX), but that won’t work also with any VARBINARY(N) type.

What should I do to make that working?
I posted test project on github TDS VARBINARY test

Where Next?

Popular in Questions Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New

We're in Beta

About us Mission Statement