string query = @"declare @strText varchar(200),
@sCdName varchar(60)
select @sCdName = CD_Name
from CompanyDepartment
where CD_Key = " + legalID + @"
set @strText = 'Изменение организации на ' + @sCdName
Insert into History(HI_DgCod, HI_Date, HI_Who, Hi_Mod, HI_Text)
VALUES('" + order.Text + @"', GetDate(), user_name(), 'UPD', @strText)";
var MTConnection = new SqlConnection(connStr);
MTConnection.Open();
SqlCommand MTCommand = MTConnection.CreateCommand();
MTCommand.CommandText = query;
MTCommand.CommandType = CommandType.Text;
MTCommand.ExecuteReader();
MTConnection.Close();
MTConnection.Dispose();