Hello All,
I have written the following piece of code ( sql clr stored procedure ) that writes messages to a local file. The problem occurs when multiple connections call the stored proc at the same time. So I used a lock statement. But this doesn't seem to make any difference? What am I doing wrong here?
lock (SqlContext.Pipe)
{
StreamWriter sw = File.AppendText("C:\Date.txt");
int y = 50;
while (y != 0)
{
sw.WriteLine(DateTime.Now + " " + serverName + " -- " + jobId.ToString() );
System.Threading.Thread.Sleep(new Random().Next());
y = y - 1;
}
sw.Close();
}