My C# application calls a stored procedure that includes the following UPDATE
statement to concatenate a VARCHAR(max)
column with the string @input
that is passed in as a parameter:
UPDATE [TblTest]
SET [txtData] = [txtData] + @input
WHERE [TblTestID] = @id
@input
will typically have a length of a million characters.
The stored procedure is called multiple times. As the length of the string stored in txtData
column increases, the performance of the UPDATE
statement degrades considerably. E.g. it takes over 30 seconds to execute when txtData
has over 300 million characters, with just a single record in the table.
Are there any options available to optimise the SQL to improve performance? I'm using SQL Server 2008 R2.
Thanks for your help.