using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Security.Principal;
using System.IO;


public partial class StoredProcedures
{
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void GetFile()
    {
        string s;

        using (WindowsImpersonationContext c = SqlContext.WindowsIdentity.Impersonate())
        {
            FileStream fs = new FileStream("c:\\test.txt", FileMode.Open);
            StreamReader sr = new StreamReader(fs);
            s = sr.ReadToEnd();
            c.Undo();
        }
        SqlContext.Pipe.Send(s);
    }
};
