# Define variables.
$Source = "C:\Test\*.*"
$Destination = "C:\Testing\"
$DestinationFiles = "C:\Testing\*.*"
# Create the $sourceFileList variable to loop through
$sourceFileList = Get-ChildItem -path $Source
# Loop through the $soureFileList and copy the items to the $Destination.
foreach ($item in $sourceFileList)
{
Copy-Item -Path $Source -Destination $Destination
}
# Create the $destinationFileList variable to loop through
$destinationFileList = Get-ChildItem -path $DestinationFiles
# Loop through the $destinationFileList and rename the files with appended DateTime stamp.
foreach ($itemDest in $destinationFileList)
{
$Date = (Get-Date).ToString("yyyyMMdd_HHmmss")
$newFileName = $Date + "_" + $itemDest.Name
Rename-Item $itemDest -NewName $newFileName
}
I created this blog to keep track of database and reporting tips, tricks, and features. Some of the information on this blog is from other websites. I am re-posting here so the information I have researched will be in a central location. The majority of the information on this blog is related to SQL Server, SSRS, SSIS, SSAS, BIDS, and Report Builder. I hope the information on this blog will be helpful to others and please feel free to share thoughts, ideas, and code.
Friday, September 23, 2016
Thursday, September 15, 2016
T-SQL ESCAPE for Querying Underscores
In T-SQL the underscore is a special character when querying/filtering records.
The following code will return all records and not only those with an underscore because the underscore acts like a wildcard if not escaped.
Select * from TableName
Where ColumnName Like '%_%'
Using ESCAPE in the query will make the special character such as the underscore a literate character. The following code will return only those records that contain an underscore.
Select * from TableName
Where ColumnName Like '%\_% ESCAPE '\'
More information about ESCAPE
Subscribe to:
Posts (Atom)