I have this C# code
try
{
using (var conn = new SqlConnection(connectionString))
using (var command = new SqlCommand("deepstoredProc", conn)
{
CommandType = CommandType.StoredProcedure
})
{
command.Parameters.Add("@recid", SqlDbType.Int).Value = Int32.Parse(recid);
command.Parameters.Add("@jsonstr", SqlDbType.VarChar, -1).Value = jsonstr;
command.Parameters.Add("@text", SqlDbType.VarChar, -1).Value = txt;
conn.Open();
command.ExecuteNonQuery();
}
}
catch(Exception e)
{
WriteToSysLog("Exception execSP() " + e.Message);
}
finally
{
}
This is the SQL Server stored procedure. I am having trouble only with the update query
USE [testDatabase]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[deepstoredProc]
@recid int,
@jsonstr nvarchar(max),
@text nvarchar(max)
AS
BEGIN
UPDATE table1
SET transcript = @text,
field1 = 'Y'
WHERE recordingid = @recid
INSERT INTO othertable
VALUES (@recid, '', 'textvalue1', COMPRESS(@jsonstr), 'en')
INSERT INTO othertable
VALUES (@recid, '', 'textvalue2', COMPRESS(@text), 'en')
END
This only updates table1 transcript field with the first character of the @text value
The table column is defined as varchar(max)
.
Also note that when I run the update script in SSMS, it executes perfectly.
This is a strange problem and appreciate any help.