How to use constants in the Transact-SQL statement to represent binary forms of data?

xiaoxiao2021-03-06  87

Binary data may be images, sounds, or any other data. If we can expose these binary in the form of constant, we can use the Transcat-SQL statement to insert and update this data in the data table.

In fact, Transcat-SQL has given us a way, that is, binary constant format. This format begins with "0x", followed by several hexadecimal numbers, each byte with two hexadecimal numbers. Therefore, you can convert those image sound data into such binary constant format and then used in the INSERT or UPDATE statement.

However, such binary constants will be very long. This way, the SQL statement is difficult to see, and there is a problem in the editor in some of the lengths of some rows.

So, there is no way to pay for binary constant?

Unfortunately, I have all the way to use Transact-SQL online help, search online, there is no answer.

Is it really no way?

The road has never been in the way. Maybe the former people have passed, and the future generations don't know. Even, the road is there, and you dare not go?

So, the adventure begins:

I will force the long binary constant to break, execute, error ...

Plus "_", VB fold symbol, error ...

Replace it with "/ n", c, c string folding symbol, error ...

Causes with quotation marks, error ...

Change double quotes, error ...

..., error ...

..., error ...

..., error ...

Plus "/" in front, success!

I can't believe it, try again!

After a little surprise, I immediately keep calm: Is the data inserted correct?

Immediately, write program verification, completely correct!

It turns out that "/" is a commutation of binary constants, the road is there!

But note: In the Insert and Update statements, you can update the 8,000 bytes of data with binary constants. If you need, process larger data, use the WRITETEXT statement or the UpdateText statement and need to segment multiple times.

Li Wei. Shenzhen 2004-10-14

转载请注明原文地址:https://www.9cbs.com/read-106620.html

New Post(0)