Sunday, October 20, 2013

Selecting data from two Different SQL Servers

For selecting the data from two databases of two different servers, first we have to link the two servers.

sp_addlinkedserver('servername')

Then you can run the query like,

select * from Table1
unionall
select * from [server2].[database].[dbo].[Table1]

Read Text File using C#

Article about reading the Text file line by line using the StreamReader in C#


Namespace :

 using System.IO;

Code:

string line;

// Read the file and display it line by line.
StreamReader file = new StreamReader(@"c:\test.txt");
while((line = file.ReadLine()) != null)
{
Console.WriteLine (line);
counter++;
}

file.Close();