How do I calculate the size of files that I have UNC paths for

I am on SQL Server 2008 R2. I have a table that contains a field called [Location]. In that field is a UNC path to the physical file on the repository. Is there a way in SQL Server that I can say give me the select sum([Location] UNC file) where criteria?
I saw some posts about xp_filesize or xp_GetFileDetails, but I do not see them in master. I am unable to add anything and wondering if there is any native functionality that would allow me to accomplish this!? Thanks.

Maybe you can use an Excel Macro for this kind of thing.
Dim iRow
Sub ListFiles()
iRow = 11
Call ListMyFiles(Range("C7"), Range("C8"))
End Sub
Sub ListMyFiles(mySourcePath, IncludeSubfolders)
Set MyObject = New Scripting.FileSystemObject
Set mySource = MyObject.GetFolder(mySourcePath)
On Error Resume Next
For Each myFile In mySource.Files
iCol = 2
Cells(iRow, iCol).Value = myFile.Path
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.Name
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.Size
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.DateLastModified
iRow = iRow + 1
Next
If IncludeSubfolders Then
For Each mySubFolder In mySource.SubFolders
Call ListMyFiles(mySubFolder.Path, True)
Next
End If
End Sub
Try this too.
Sub TestListFilesInFolder()
' Open folder selection
' Open folder selection
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Select a Folder"
.AllowMultiSelect = False
If .Show <> -1 Then GoTo NextCode
pPath = .SelectedItems(1)
If Right(pPath, 1) <> "\" Then
pPath = pPath & "\"
End If
End With
NextCode: 'MsgBox "No files Selected!!"
'Application.WindowState = xlMinimized
'Application.ScreenUpdating = False
Workbooks.Add ' create a new workbook for the file list
' add headers
ActiveSheet.Name = "ListOfFiles"
With Range("A2")
.Formula = "Folder contents:"
.Font.Bold = True
.Font.Size = 12
End With
Range("A3").Formula = "File Name:"
Range("B3").Formula = "File Size:"
Range("C3").Formula = "File Type:"
Range("D3").Formula = "Date Created:"
Range("E3").Formula = "Date Last Accessed:"
Range("F3").Formula = "Date Last Modified:"
Range("A3:F3").Font.Bold = True
Worksheets("ListOfFiles").Range("A1").Value = pPath
Range("A1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.Font.Bold = True
ListFilesInFolder Worksheets("ListOfFiles").Range("A1").Value, True
' list all files included subfolders
Range("A3").Select
Lastrow = Range("A1048576").End(xlUp).Row
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("ListOfFiles").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("ListOfFiles").Sort.SortFields.Add Key:=Range( _
"B4:B" & Lastrow), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("ListOfFiles").Sort
.SetRange Range("A3:F" & Lastrow)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A1").Select
Cells.Select
Cells.EntireColumn.AutoFit
Columns("A:A").Select
Selection.ColumnWidth = 100
Range("A1").Select
End Sub
Sub ListFilesInFolder(SourceFolderName As String, IncludeSubfolders As Boolean)
' lists information about the files in SourceFolder
Dim FSO As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder
Dim FileItem As Scripting.File
Dim r As Long
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(SourceFolderName)
r = Range("A1048576").End(xlUp).Row + 1
For Each FileItem In SourceFolder.Files
' display file properties
Cells(r, 1).Formula = FileItem.Path & FileItem.Name
Cells(r, 2).Formula = (FileItem.Size / 1048576)
Cells(r, 2).Value = Format(Cells(r, 2).Value, "##.##") & " MB"
Cells(r, 3).Formula = FileItem.Type
Cells(r, 4).Formula = FileItem.DateCreated
Cells(r, 5).Formula = FileItem.DateLastAccessed
Cells(r, 6).Formula = FileItem.DateLastModified
' use file methods (not proper in this example)
r = r + 1 ' next row number
Next FileItem
If IncludeSubfolders Then
For Each SubFolder In SourceFolder.SubFolders
ListFilesInFolder SubFolder.Path, True
Next SubFolder
End If
Columns("A:F").AutoFit
Set FileItem = Nothing
Set SourceFolder = Nothing
Set FSO = Nothing
ActiveWorkbook.Saved = True
End Sub
Sub CreateList()
Application.ScreenUpdating = False
Workbooks.Add ' create a new workbook for the folder list
' add headers
ActiveSheet.Name = "ListOfFiles"
With Cells(3, 1)
.Value = "Folder contents:"
.Font.Bold = True
.Font.Size = 12
End With
Cells(4, 1).Value = "Folder Path:"
Cells(4, 2).Value = "Folder Name:"
Cells(4, 3).Value = "Folder Size:"
Cells(4, 4).Value = "# Subfolders:"
Cells(4, 5).Value = "# Files:"
Range("A3:E3").Font.Bold = True
ListFolders BrowseFolder, True
Application.ScreenUpdating = True
Cells.Select
Cells.EntireColumn.AutoFit
Columns("A:A").Select
Selection.ColumnWidth = 100
Columns("B:B").Select
Selection.ColumnWidth = 25
Range("A1").Select
End Sub
Sub ListFolders(SourceFolderName As String, IncludeSubfolders As Boolean)
' lists information about the folders in SourceFolder
Dim FSO As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder
Dim r As Long
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(SourceFolderName)
' display folder properties
Worksheets("ListOfFiles").Range("A1").Value = SourceFolderName
Range("A1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.Font.Bold = True
r = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(r, 1).Value = SourceFolder.Path
Cells(r, 2).Value = SourceFolder.Name
Cells(r, 3).Value = SourceFolder.Size
Cells(r, 3).Value = (SourceFolder.Size / 1048576)
Cells(r, 3).Value = Format(Cells(r, 3).Value, "##.##") & " MB"
Cells(r, 4).Value = SourceFolder.SubFolders.Count
Cells(r, 5).Value = SourceFolder.Files.Count
If IncludeSubfolders Then
For Each SubFolder In SourceFolder.SubFolders
ListFolders SubFolder.Path, True
Next SubFolder
Set SubFolder = Nothing
End If
Columns("A:E").AutoFit
Set SourceFolder = Nothing
Set FSO = Nothing
ActiveWorkbook.Saved = True
End Sub
And, finally.
Const BIF_RETURNONLYFSDIRS As Long = &H1 ''' For finding a folder to start document searching
Const BIF_DONTGOBELOWDOMAIN As Long = &H2 ''' Does not include network folders below the domain level in the tree view control
Const BIF_RETURNFSANCESTORS As Long = &H8 ''' Returns only file system ancestors.
Const BIF_BROWSEFORCOMPUTER As Long = &H1000 ''' Returns only computers.
Const BIF_BROWSEFORPRINTER As Long = &H2000 ''' Returns only printers.
Const BIF_BROWSEINCLUDEFILES As Long = &H4000 ''' Returns everything.
Const MAX_PATH As Long = 260
Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszINSTRUCTIONS As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Declare Function SHGetPathFromIDListA Lib "shell32.dll" (ByVal pidl As Long, ByVal pszBuffer As String) As Long
Declare Function SHBrowseForFolderA Lib "shell32.dll" (lpBrowseInfo As BROWSEINFO) As Long
Function BrowseFolder() As String
Const szINSTRUCTIONS As String = "Choose the folder to use for this operation." & vbNullChar
Dim uBrowseInfo As BROWSEINFO
Dim szBuffer As String
Dim lID As Long
Dim lRet As Long
With uBrowseInfo
.hOwner = 0
.pidlRoot = 0
.pszDisplayName = String$(MAX_PATH, vbNullChar)
.lpszINSTRUCTIONS = szINSTRUCTIONS
.ulFlags = BIF_RETURNONLYFSDIRS
.lpfn = 0
End With
szBuffer = String$(MAX_PATH, vbNullChar)
''' Show the browse dialog.
lID = SHBrowseForFolderA(uBrowseInfo)
If lID Then
''' Retrieve the path string.
lRet = SHGetPathFromIDListA(lID, szBuffer)
If lRet Then BrowseFolder = Left$(szBuffer, InStr(szBuffer, vbNullChar) - 1)
End If
BrowseFolder = BrowseFolder & "\"
End Function
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

Similar Messages

  • How to go to the location of file that I received ...

    How to go to the location of file that I received on skype? I was able to do it easily in old version. 
    Now, I recieved the zip file. If I click on the file, it shows the Zip File View. I don't know where that file is downloaded. (of cuz, need to dip where I set the download path.) In old version of Skype, there is a link where we can open the file in windows explorere.
    I would suggest that the Skype UX or development team needs to read "Don't make me think" short book. 
    Update: There are other people who reported the issues in 2013 http://community.skype.com/t5/Modern-Windows-from-​Windows/Where-are-the-files-saved-that-someone-sen​... Please don't copy all metro skype UI to skype desktop without thinking about usability and royal user expereince. Thanks! 
    Note: Another thing: THis forum seems like it let me post without me logging in. But when I submit the context, it redirects to login page. So, I chose to login with my account and it redirect back me to this forum and the post that I wrote a few min ago was totally gone.. Seriously? 
    Solved!
    Go to Solution.
    Attachments:
    Fuck New UI.png ‏9 KB

    What about this?
    Attachments:
    ShowInFolder.jpg ‏28 KB

  • HT4623 How can I save the update download file as I have several devises to upgrade and cant afford the bandwidth to do each via iTunes

    How can I save the update download file as I have several devises to upgrade and cant afford the bandwidth to do each via iTunes.
    There does not appeare to be any doenloadable files in the download section.

    "Well that's totally unacceptable."
    Actually you can only accept it, as it is the way it is.  You may not like it, but it is so.  Sorry.
    " your seriously telling me that Apple expect me to download the same huge file 8 TIMES"
    That is exactly what I am telling you.
    " No way."
    Still true.
    "Apple are going to have to come up with another solution."
    No.  They do not have to do any such thing.  They may choose to do so in the future, but there is no reason to believe that they will.

  • HT1926 My installation of Itunes to syne my iphone with PC was missing AppleApplicationSupport.msi  after 2 installs how can I install such a file do you have a path for this

    My installation of Itunes to syne my iphone with PC was missing AppleApplicationSupport.msi  after 2 installs how can I install such a file do you have a path for this

    Hi kensb!
    I would recommend that you attempt to reinstall all of the programs and components of iTunes on your machine and reinstall everything again. It can be tricky to get everything uninstalled, so we have an article that can help you make sure you uninstall everything:
    Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
    http://support.apple.com/kb/ht1925
    or
    Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7
    http://support.apple.com/kb/ht1923
    Specifically, when it comes to uninstalling, you will want to uninstall applications in this order:
    Use the Control Panel to uninstall iTunes and related software components in the following order. Then, restart your computer.
    iTunes
    QuickTime
    Apple Software Update
    Apple Mobile Device Support
    Bonjour
    Apple Application Support (iTunes 9 or later)
    Important: Uninstalling these components in a different order, or only uninstalling some of these components may have unintended effects.
    You will then want to follow the links in those articles to download the latest package of iTunes software for your computer and install again from there. Thanks for being a part of the Apple Support Communities!
    Regards,
    Braden

  • How do I see the number of albums that I have import to my Itunes?

    How do I see the number of albums that I have import to my Itunes?
    In the earlier version of Itunes I could see the number of albums, categories etc. that I have in my Itunes. How do I see the same info in Itunes 7.1.1?
    Best Kudsk

    Go to View>Show Browser and switch on the browser pane. At the top of the three categories Genre, Artist and Album you'll see "All" and the totals in brackets.

  • How do I view and manage certain files that I have stored in iCloud? I know that I can delete an entire backup, but is it possible to delete certain photos/contacts/notes etc. from that backup?

        How do I view and manage certain files that I have stored in iCloud? I know that I can delete an entire backup, but is it possible to delete certain photos/contacts/notes etc. from that backup?

    No.

  • How do I delete the few hundred records that I have double or triple of

    how do I delete the few hundred records that I have double or triple of

    is there a way to delete thse extra files

  • How do I change the size of file menu's and tool icons in Photoshop' opening page.

    How do I increase or change the size of file menu's and tool icons on the opening page/worksheet of Photoshop? The File Menu drop down commands read properly at a comfortable size. I am not sure how I accomplished this, but everything I have tried has no effect on the other page items.

    Hello, you can change most of Photoshop's interface text by going to preferences>interface>UI font size.
    For the size of the top menus and the whole interface, there is no function to do that for the moment. I suggest to vote on this thread: http://feedback.photoshop.com/photoshop_family/topics/problem_with_hi_res_monitors

  • How do i calculate the average of runs that have variable number of samples?

    Hi
    I am trying to calculate the average trajectory from  lets say 4 runs, with varying sample size.
    That is, if the the 4 runs have 78,74,73,55 samples respectively, How do I calculate the average of (78+74+73+55)/4 , (78+74+73)/3 and (78+74)/2  and 78/1 ?
    Thank you

    I'm not sure you gave a sufficient information. Assuming that you just want to calculate a linear average of the data collected in consecutive runs, you have two simple methods :
    1/ concatenate the data before calculating the mean.
    Simple, but can occupy a huhe amount of space since all the data have to be stored in memory
    2/ store only the means Mi and the corresponding number of data points ni and calculate a balanced mean : M = sum (ni x Mi) / sum (ni) )
    The attached vi illustrate both methods.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Averages.vi ‏40 KB

  • HT1222 How do I increase the total amount of space I have on iPhone for things like iTunes n more music n like MusicTube n YouTube. Thank you in advance for any help that can be given.

    I am running out of usage space. How do I increase the total amount of space I have on my iPhone4S: for things like programs &amp; apps such as, iTunes &amp; more music &amp; like MusicTube &amp; YouTube. The only reason I have any space now is because the music that I had downloaded and synced onto my phone from iTunes I had to take it all off. I would really really love to be able to put my music back onto my iPhone. Currently I'm using apps like Spotify, AOLradio, and MusicTube to listen to music. Thank you so very much in advance for any help that may be given!

    Also to add to my original question: is what I'm asking even a possibility??? Meaning is there even a way to get more usage space? Or do I have to just continue to work within the confines that apple has preset on the phone?

  • I can no longer open my files that I have been using for years?

    I can no longer open my documents that I have been using for years.
    "Adobe Reader could not open xxxx.jpg because it is not a supported file type or ................."
    Help.

    Here are instructions for setting file associations for Windows 8. Again, you will need to know what program you have that opens .jpg files.
    How to Associate File Types in Windows 8: 5 Steps (with Pictures)
    Good luck.

  • How to find out the size of files transferred over the SQL * Net?

    I am trying to test the Advanced Compress (AC) for 11g Data Guard. When the AC is turned on, the archived log files are supposed to be compressed on the primary database server and sent over SQL*Net, then decompressed on the standby db server. We will see the file sizes are the same on both primary and standby servers. I want to verify that the AC works by monitoring how much data are sent over SQL*Net. Per Oracle, AC uses 35% less of the bandwith. That means the size of the files transferred should be at least 65% of the original size.
    Is there a way to find out the size through Oracle utilities? If not, how to find out by OS utilities? OS is Solaris 5.10.
    Thanks.

    I'm not sure this can be done via SQL*Net, but a network packet sniffer between the two servers should be able to help - you might want to contact your network team.
    HTH
    Srini

  • Calculate the size(in bytes) that will be displayed to the console by command Write-Output

    Is there some way to check the size(in bytes) of the output that will be displayed to the console using Write-Output command. I want the console to display only the first 1024 bytes of the objects output.

    Hi Sachin,
    in that case let me add an example on how to read content from a file that may be or may not be a text file:
    $string = [System.Text.Encoding]::UTF8.GetString([System.IO.File]::ReadAllBytes("D:\example.txt"))
    Theoretically, the "Get-Content" cmdlet ought to do the same, however I have occasionally experienced different results.
    You can choose to not convert it to string and just print the bytes too (or choose another encoding of your preference). Remember, a single letter usually uses 2 bytes, thus reading the first 1024 bytes from a file you converted to text would mean printing
    the first 512 letters.
    Cheers,
    Fred
    There's no place like 127.0.0.1

  • How can I view from Forms 6 the name of files that i have in a directory?

    Hy !
    I need some help :(
    I want to make a form. This form must tell me the name of the files that are in a directory.
    How can i do that ?
    Thanks!

    Hello,
    If you are using the C/S deploiement mode, you could find all that you want in the d2kwutil.pll library.
    Francois

  • How can I limit the size of emails that are downloaded in Mail 6.2

    I currently have limited bandwith.  How can I set up Mail 6.2 to only download email headers for messages greater than 50 kb in size

    Thank you. I just needed to be pointed in the right direction. After looking over this stuff, including FilePermission, I think this may give me what I was looking for. It will be a while before I get to implementing it or testing something like this, I'm just trying to get a grasp on all of the things I need to do and how to approach it.
    By doing this I can control how much filespace it can use.
    I can control CPU usage by monitoring for extra threads that don't belong and killing or settings the priority on it.
    Now I just need to think of something to monitor how much memory the plugin uses. I suppose I could gc, then store the current memory usage, then execute the plugin, gc again, and measure the size again. Does that sound like a reasonable way to estimate it's memory usage? I'm not looking for tiny changes, I just want to see large, substantial increases.

Maybe you are looking for