Remove Duplicate Rows from a Table in SQL Server:
                    Duplication rows in database tables will exists by running the data repeatedly With out  having the primary key on table. Here is an example to remove the duplicate records  from a table in SQL Server

                             

DELETE FROM Employee emp1 WHERE ROW_NUMBER()<>(SELECT MIN( ROW_NUMBER())FROM       EMployee emp2 WHERE emp1.empname= emp2.empname) 

Please share this post if it's useful to you. Thanks!.
Read more ...

Create log file in asp.net using C#:
                                       .NET have a various classes to create, write  on a text file which are file .Here I'm using create() method to create a text file and using some classes to reading and writing text files those are TextReader,StreamReader,StreamWriter,TextWriter classes.These are abstract classes .Here i have taken a logfilepath which is the physical path of the text file.If the file is existing in path then we will write message into this text file.If the file is not existing in the path then we will create a file in this path and write a (log) messages into it

                         
Code:

public static string strPath = AppDomain.CurrentDomain.BaseDirectory;
public static string strLogFilePath = strPath + @"log\log.txt";
public static void WriteToLog(string msg)
 {
  try
   {
    if (!File.Exists(strLogFilePath))
       {
       File.Create(strLogFilePath).Close();
       }
    using (StreamWriter w = File.AppendText(strLogFilePath))
       {
        w.WriteLine("\r\nLog: ");
        w.WriteLine("{0}",DateTime.Now.ToString(CultureInfo.InvariantCulture));
        string err = "Error Message:" + msg;
        w.WriteLine(err);
        w.Flush();
        w.Close();
       }
   }
Please share this post if it's useful to you. Thanks!.
Read more ...

Related Posts Plugin for WordPress, Blogger...