0

I have basic SQL knowledge and wondering if it is possible to run a command or some type of script that will iterate through a query result and for each record, extract the fulltext data and save it to a text file on my local drive?

Thank you!

user7321
  • 1
  • 1
  • possible duplicate of [Script to save varbinary data to disk](http://stackoverflow.com/questions/4056050/script-to-save-varbinary-data-to-disk) –  Feb 06 '14 at 20:58
  • Thanks for the pointer SaUce. Can fulltext data be extracted like any other column using the Select statement in the example script? In other words, can I simply use: DECLARE IMGPATH CURSOR FAST_FORWARD FOR SELECT myFulltext from myTable – user7321 Feb 06 '14 at 21:32

1 Answers1

0

You may use bcp utility :

DECLARE @SQL VARCHAR(1000)

-- EXPORT ITEMS

SET @SQL = ' BCP dbo.ITEMS out '
SET @SQL = @SQL + 'C:\FOLDER\ITEMS.CSV -T -t; -c -C UTF-8 -S'
EXEC xp_cmdshell @SQL
chris
  • 1
  • Thanks chris. This would export everything in the table, all columns and also the fulltext, correct? Can I limit it to export only the fulltext? – user7321 Feb 06 '14 at 23:04
  • Yes everything. You could prepare a select statement. I usually create a view with desired fields and export it instead just to have a clear bcp syntax. – chris Feb 11 '14 at 21:23