Thursday, September 27, 2012

SQL Server 2008 Arithmetic Calculations


Today I small arithmetic calculations in SQL Server 2008 Please find the below.

SQL Server arithmetic calculation Add, Subtract, Multiple and Divide

select 0+0 as test1, (0/cast((0+0) as decimal(5,1))*100) as test2

Monday, September 17, 2012

Robocopy used to move, copy files from one server to other server

Reference:
http://technet.microsoft.com/en-us/library/cc733145.aspx


:begin
@echo off

@set SourcePath=\\<<Server Name>>\<<Folder Name>>
@set DestinationPath=\\<<Server Name>>\<<Folder Name>>

echo --- Moving Files from one Server to Another Server  ---
ROBOCOPY %SourcePath% %DestinationPath% /mov


if errorlevel == 0 goto :success

echo ### Error in Moving Files from %SourcePath% to %DestinationPath%
echo .
goto end

:success
echo Successfully Moved Files from %SourcePath% to %DestinationPath%
echo .
goto end

:end


Friday, September 14, 2012

Download all the content of a list/document library to a file share.

Download all the content of a list/document library to a file share. This script should ensure the folder structure of the document library to be replicated in the file share.
######################## Start Variables ########################
######################## Varun's Script######################
$destination = "C:\\tools\\Folder"
$webUrl = "<Url of the specific site>"
$listUrl = "<Url of the specific list. This url is complete Url and NOT relative url>"
##############################################################

$web = Get-SPWeb -Identity $webUrl
$list = $web.GetList($listUrl)

function ProcessFolder {
    param($folderUrl)
    $folder = $web.GetFolder($folderUrl)
    foreach ($file in $folder.Files) {
        #Ensure destination directory
        $destinationfolder = $destination + "/" + $folder.Url
        if (!(Test-Path -path $destinationfolder))
        {
            $dest = New-Item $destinationfolder -type directory
        }
        #Download file
        $binary = $file.OpenBinary()
        $stream = New-Object System.IO.FileStream($destinationfolder + "/" + $file.Name), Create
        $writer = New-Object System.IO.BinaryWriter($stream)
        $writer.write($binary)
        $writer.Close()
        }
}

#Download root files
ProcessFolder($list.RootFolder.Url)
#Download files in folders
foreach ($folder in $list.Folders) {
    ProcessFolder($folder.Url)
}



 Awesome Blog for PowerShell Scripts. Thank you Varun.


Powershell Script to Importing & Exporting sites in SharePoint 2010

SharePoint 2010 we can import and export sites, lists, document libraries and items using Export-SPWeb and Import-SPWeb.

Export-SPWeb http://SP/TeamSite –Path C:\Backup\website.bak

If we only want to export a list in a site you can use –ItemUrl parameter as shown below:

Export-SPWeb http://SP/TeamSite -ItemUrl “Lists/<<MyList>>” `
–Path C:\Backup\website.bak

We can use the Import-SPWeb cmdlet to import the exported files to SharePoint 2010.

Import-SPWeb http://SP/TeamSite –Path C:\Backup\website.bak


SSIS 2008 with Team Foundation Server 2010

Case
A lot of my clients are still working with SSIS 2008 (R2), but already have Team Foundation Server 2010 for source control. How can you connect to TFS 2010 with BIDS/Visual Studio 2008?

 http://microsoft-ssis.blogspot.com/2012/04/ssis-2008-with-team-foundation-server.html


Thanks to Microsoft for  this excellent workaround.

Monday, September 10, 2012

Access Denied error while trying to Preview TFS Added SSRS Report


Access Denied error while trying to Preview SSRS Repor

You might get a message "An error occurred during local report processing. Access Denied. (Exception from HRESULT: 0x80030005 (STG_E_ACCESSDENIED))" while you try to preview a report you developed under VS 2008 and which has been added to TFS or any source control.

The reason for this is due to the .data file associated to the report which is read only state. You can resolve this issue by either checking out the .data file or un-checking the read-only attribute of the file under local folder.


Here is a nice article post by about the issue