• No problem. 🙂

    Ok, so what exactly will you be passing to the function? Something like 'C:\Somedir\SomeOtherDir\'? What do you want returning from the function?

    Also, what do you need it for?

    What might work (and I say might, because I'm not a C# expert) is to change the function you gave to something like this.

    public static long DirSize(SQLString dir)

    {

    DirectoryInfo d = new DirectoryInfo((String) dir);

    long Size = 0;

    Now you can create that function in SQL with a nvarchar(4000) parameter (I don't think it'll take varchar(MAX), though if you have directory trees more than 4000 characters wide, I'd worry for other reasons).

    The cast to String may or maynot be necessary. Try both ways, see what works.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass