0

this is pretty much a noob question but i can't find a solution.

I'm using a SQL Server Database. In one table a column has the DataType varbinary(max). The values for this column are shown a hex values(When i'm using a select - query). What is the best way to write the shown hex String completly into a text file?

Two Constraints: * Copy&Paste is not an Option. The value i want to extract has a length of approx. 69000 Chars. The Windows Clipboard seems to store only around 43000 Chars. * I've tried to save the query Result as a .csv File. But the maximum size for these files is around 65000 chars.

Patrick
  • 585
  • 8
  • 22
  • Why can't you query that column, store it in a StringBuffer and then write it to a File? – PbxMan Feb 22 '13 at 09:00
  • Would this answer help? http://stackoverflow.com/a/5172100/2061621 – Kai Feb 22 '13 at 09:03
  • Using transact SQL? Or Java? I've been using a small Java Program to query the value. But i don't know which method to call to get the hex value and not the bytes. – Patrick Feb 22 '13 at 09:05

1 Answers1

1

From the command line:

bcp "select * from [<yourtable>]" queryout C:\Temp\yourfile.dat -S yourserver -d yourDatabase -T -c

-T means a Trusted Connection; you can use -U and -P to supply a user name as password.

muhmud
  • 4,474
  • 2
  • 15
  • 22
  • Whooohoooo!!! :-) Works! Thanks. I've tried bcp yesterday but did not give the Database as an extra Parameter. I've had it in my query. – Patrick Feb 22 '13 at 09:20