Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 help with binary data insertion

Author  Topic 

mani6961
Starting Member

10 Posts

Posted - 2013-08-20 : 10:47:22
Hi all,

I am having trouble inserting some binary data into a table. It has a column: varbinary(max) and this insert statement is not working:

The binary is very long, but I would have assumed that varbinary(max) could store it:

exec sp_executesql N'insert into Test(ImageCol) values @IMAGE',N'@IMAGE varbinary(max)',@IMAGE=0xFFD8FF....680680680680680680680FFD9

It keeps reporting an error suggesting incorrect syntax, and that "the identifier that starts with 'A01......' is too long. It's as though my syntax is incorrect.

I've also tried
insert into Test(ImageCol) values 0xFFD8FF....680680680680680680680FFD9

and it's the same error (which I expected)

I hope that it is something small, or perhaps it is just sheer ignorance.


Thanks for any help.



-Ty

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-08-20 : 10:52:46
I am not familiar with that error message about the identifier being too long, but regardless, your insert statement requires a pair of brackets
insert into Test(ImageCol) values (0xFFD8FF....680680680680680680680FFD9)
Go to Top of Page

mani6961
Starting Member

10 Posts

Posted - 2013-08-20 : 11:03:12
Makes sense about the brackets, but same error with\without them.

-Ty
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-08-20 : 11:16:01
How long is your binary? I tried to insert a binary value that is 1,134,300 long, and it succeeded. Also, I don't see any identifier that starts with A01 in anything you posted. Look for A01 in your query and see what goes on there.
Go to Top of Page

mani6961
Starting Member

10 Posts

Posted - 2013-08-20 : 11:28:14
It is around 133,000 characters, so it's rather large to post the entire string. The A01 is there, but it seems like there is an issue with the syntax on the 2nd line.
So for your insert you just have
insert into YourTable(YourImage) value (0xF....F)
where the binary is
over 1 million characters long?

-Ty
Go to Top of Page

mani6961
Starting Member

10 Posts

Posted - 2013-08-20 : 11:29:23
I put everything on the same line and it worked (with the brackets)

Thanks guys.

-Ty
Go to Top of Page
   

- Advertisement -