SET @UploadDir = ‘\\MyServer\data\’
SET @UploadFileName = ‘test.txt’
SET @UploadData = ' echo ' + @HoldRecNo + ',' + @Name + ',' + @Terms + ',' + @Description + ',' + CONVERT(char(8), @DueDate,1) + ',' + CONVERT(char(8), @PayDate,1) + ',' + CONVERT(varchar(15), @Amount) + ',' + @InvoiceNo + ',' + CONVERT(char(8), @InvoiceDate, 1) + ',' + CONVERT(varchar(15), @Amount) + ',' + ‘ >> ' + @UploadDir + @UploadFileName
EXEC master..xp_cmdshell @UploadData
I am having a problem writing data to a text file, via a stored procedure. The problem is the variable @Name contains: ‘C&W Store’.
Once it hits the & sign, it treats it like a new line or return character. I thought about converting the & sign, but the problem is this text
file is going to be uploaded by another program and is uploading by @Name, so if I convert the & sign, the data will never be
uploaded because it won’t be able to find the matching name. Does anyone have any ideas on getting around this? Any help would be
greatly appreciated.
SET @UploadFileName = ‘test.txt’
SET @UploadData = ' echo ' + @HoldRecNo + ',' + @Name + ',' + @Terms + ',' + @Description + ',' + CONVERT(char(8), @DueDate,1) + ',' + CONVERT(char(8), @PayDate,1) + ',' + CONVERT(varchar(15), @Amount) + ',' + @InvoiceNo + ',' + CONVERT(char(8), @InvoiceDate, 1) + ',' + CONVERT(varchar(15), @Amount) + ',' + ‘ >> ' + @UploadDir + @UploadFileName
EXEC master..xp_cmdshell @UploadData
I am having a problem writing data to a text file, via a stored procedure. The problem is the variable @Name contains: ‘C&W Store’.
Once it hits the & sign, it treats it like a new line or return character. I thought about converting the & sign, but the problem is this text
file is going to be uploaded by another program and is uploading by @Name, so if I convert the & sign, the data will never be
uploaded because it won’t be able to find the matching name. Does anyone have any ideas on getting around this? Any help would be
greatly appreciated.