views:

16

answers:

1

Hi,

How do we transfer the content of a string variable to a file on a SP? I need to do these:

  1. Create an empty text file from an SP
  2. Push the content of a variable (whose len is 25487) to the newly created file

The variable size is Varchar(Max), and this is the code I am trying to make work (but it ain't [Sad] ) ---

Declare @cmd sysname Declare @ReqContent Varchar(max)

SET @cmd = 'echo ' + @ReqContent + ' > C:\DD4TRD.txt' EXEC master..xp_cmdshell @cmd ,NO_OUTPUT

Thanks, Sayan

+1  A: 

Check out this sproc from Reading and Writing Files in SQL Server using T-SQL.

JP Alioto