Is there way to get file from windows xp command prompt? I tried to run xp_cmdshell 'type [path to file]'
but then when i insert theese data into other file and renaming it to file.exe (that is executable) it does not work. Any suggestions how to get file contents in such way that i can use it?
You could use BULK INSERT on the file and treat the file as a table with one row and one column. This should allow you to read the file directly into a VARBINARY field
Like this:
CREATE TABLE FileRead
(
content VARBINARY(MAX)
)
BULK INSERT FileRead FROM [FilePath]
This requires SQL Server to have access to the file you are trying to read. It sounds like you are trying to "acquire" executables from a server you do not have access to? :-)
来源:https://stackoverflow.com/questions/10674987/get-file-contents-via-xp-cmdshell