SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 help with binary data insertion
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mani6961
Starting Member

Canada
10 Posts

Posted - 08/20/2013 :  10:47:22  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3587 Posts

Posted - 08/20/2013 :  10:52:46  Show Profile  Reply with Quote
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

Canada
10 Posts

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

-Ty
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3587 Posts

Posted - 08/20/2013 :  11:16:01  Show Profile  Reply with Quote
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

Canada
10 Posts

Posted - 08/20/2013 :  11:28:14  Show Profile  Reply with Quote
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

Canada
10 Posts

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

Thanks guys.

-Ty
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000