on 2015 Aug 25 12:01 PM
How to use the SQL statement to save the RAR or EXE file in binary mode, and also can use the SQL statement to export and save the local file
Request clarification before answering.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It looks like it worked... what's the problem?
Posting an image with no explanation is rude behavior... everyone here has better things to do than try to read your mind.
'I have two windows 2008 R2 server: A server b server Use A Computer: CREATE TABLE aaa( updateexe LONG BINARY COMPRESSED ); 1. insert into aaa (updateexe) select xp_read_file ('c: \\\\ windows \\ system32 \\\\ notepad.exe') Upload --read notepad.exe notepad.exe get insert statements 2. The next generation insert statementINSERT INTO "DBA". "Aaa" ("updateexe") VALUES (0x4d5a90000300000004000000ffff0000b8000000000000004000000000000000 00000000000000000000000000000000000000000000000000000000e00000000e1 fba0e00b409cd21b8014ccd21546869732070726f6772616d2063616e6e6f742062 652072756e20696e20444f53206d6f64652e0d0d0a2400000000000000b2bec262f 6dfac31f6dfac31f6dfac31ffa73931f5dfac31ffa73f31ebdfac31f6dfad3100df ac31ffa72f31e9dfac31ffa72831f4dfac31ffa73831f7dfac31ffa73d31f7dfac3 152696368f6dfac3100000000000000000000000000000000504500004c0104000f c65b4a0000000000000000e00002010b01090000a80000) 3. Using ISQL (interactive SQL) connection B Computer ASA Insert binary data 4. already connected to the computer B ASA execution: select xp_write_file ('d: \\\\ Nnotepad.exe', updateexe) from aaa --save as d: \\ Nnotepad.exe Save the notepad.exe to D: Problem: D: \\ notepad.exe not run '
If you plan on reading a .RAR/.EXE from the file system and store/retrieve those into/from a table you can use the XP_READ_FILE( ) and XP_WRITE_FILE( ) system procedures.
You can also just access the files directly using a Directory Access Server and leaving the files on the file system but still have access to them via SQL.
HTH
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1 how to convert update.exe binary save to the database, because the use of the xp_read_file function will save is garbled!
2 the client uses any statement to convert back to EXE file pls see picture
3.Does ASA have FILESTREAM concept for user MSSQL: insert into s1(data) SELECT * FROM OPENROWSET(BULK N'd:\\19991030172400.rar', SINGLE_BLOB) AS Document
xp_read_file() and xp_write_file() work with binary data (i.e. a LONG BINARY data type), so they should not garble anything at all. May it be that you use a LONG VARCHAR (or LONG NVARCHAR) variable/column instead to set/receive the data or to the store that in the according table? Then I guess the usual charset/collation issues could take place between database engine and client...
As the the FILESTREAM question: See that according question:
Does SQL Anywhere have an equivalent feature as compared to Microsoft SQL Filestream?
I have two windows 2008 R2 server: A server b server Use A Computer: 1.
insert into aaa (updateexe) select xp_read_file ('c: \\ windows \\ system32 \\ notepad.exe')
Upload --read notepad.exe notepad.exe get insert statements 2.
The next generation insert statement INSERT INTO "DBA". "Aaa" ("updateexe") VALUES (0x4d5a90000300000004000000ffff0000b800000000000000400000000000000000000000000000000000000000000000000000000000000000000000e00000000e1fba0e00b409cd21b8014ccd21546869732070726f6772616d2063616e6e6f742062652072756e20696e20444f53206d6f64652e0d0d0a2400000000000000b2bec262f6dfac31f6dfac31f6dfac31ffa73931f5dfac31ffa73f31ebdfac31f6dfad3100dfac31ffa72f31e9dfac31ffa72831f4dfac31ffa73831f7dfac31ffa73d31f7dfac3152696368f6dfac3100000000000000000000000000000000504500004c0104000fc65b4a0000000000000000e00002010b01090000a80000)
Using ISQL (interactive SQL) connection B Computer ASA Insert binary data
already connected to the computer B ASA execution:
select xp_write_file ('d: \\ Nnotepad.exe', updateexe) from aaa --save as d: \\ Nnotepad.exe Save the notepad.exe to 😧
Problem: D: \\ notepad.exe not run
User | Count |
---|---|
74 | |
20 | |
9 | |
8 | |
7 | |
5 | |
5 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.