In a Transact-SQL statement, how does one use constants to represent binary data?

Source: Internet
Author: User
Binary data may be images, sounds, or any other data. If we can express these binary values as constants, we can directly use the transcat-SQL statement to insert and update the data in the data table.
In fact, transcat-SQL has provided us with a method, that is, the binary constant format. This format starts with "0x", followed by several hexadecimal numbers. Each byte is represented by two hexadecimal numbers. Therefore, you can convert the image sound data to this binary constant format and then use it in the insert or update statement.
However, such binary constants will be very long. In this way, SQL statements are difficult to look at, and there are still problems in the editor with limited line length.
So there is no way to fold binary constants?
Unfortunately, I checked the online help of transact-SQL and searched the network without any answer.
Is there really no way?
A path can always be taken after someone passes it. Maybe our predecessors have traveled before, but they do not know. Even, the road was there, and you dare not go?
As a result, the adventure begins:
I forcibly break the long binary constant, execute it, and make an error...
Add "_" and VB line breaks in the previous line. An error occurred...
An error occurred while changing to the line symbol of the "/N", C, C ++ string...
Error Caused by quotation marks...
An error occurred while changing double quotation marks...
..., Error...
..., Error...
..., Error...
Add "/" to the previous line. Success!
I can't believe it. Try again!

After a little surprise, I immediately kept calm: Is the inserted Data correct?
Now, write a program for verification, which is completely correct!

The original "/" is a line break of a binary constant, and the path is there!

Note: In insert and update statements, up to 8000 bytes of data can be updated with binary constants. If necessary, use the writetext statement or updatetext statement to process larger data, and perform multipart processing.

Li Zhan. Shenzhen 2004-10-14

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.