push binary files into a table

  • Hi everyone

    Happy new year to all.

    I pulling 29 files through ftp and coverting them from asci to binary vi script.

    I wounder if anyone can help or having script on how can i push these 29 files into a table?

    Do have to great a table first in the sql server db?

    than to run some script to do the above task. any info will be valuable

  • There is a wonderful little-known command line tool called textcopy.exe - it is somewhere in the program files\microsoft sql server folder.  You can use its command line switches to have it import a particular file into a particular table/field/row.  A combination of some simple TSQL to create the table rows and then some use of xp_cmdshell in a cursor will let you import the data.

    Alternatively you could write a simple app which does the import using ADO/ADO.NET, etc.

  • For uploading the file to a table.

    instead of using a .exe and xp_cmdshell you can use "bulk insert" with the raw option.

    Will be faster and will not need to leave the SQL enviroment.

  • Didn't know about the raw option on bulk insert (haven't used bulk insert that much).  From reading BOL it appears that you have to have field terminators, row terminators, etc...  Do you have examples of bulk insert with raw importing a binary file?

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply