1: set-location c:\dev\codefiles
2: $count = 0
3: $files = Get-ChildItem -Recurse -File `
4: #if we want to filter the files based on date range
5: `#| Where-Object { $_.CreationTime -ge "12/13/2017" -and $_.CreationTime -le "12/29/2017" } `
6: ForEach($file in $files)
7: {
8: if ( (Get-Content $file -Raw).Contains("shipsite=`"KeywordToFind`""))
9: {
10: write-host $file; $count++;
11: }
12: }
13: Write-Host "count of files containing word:$count
Tuesday, 14 July 2020
Counting of files containing keyword in Powershell
When we want to see how many files are using a specific keyword, we can use below powershell script to do this.
This will be helpful if we want to estimate the amount of code changes needed for a keyword change.
Loading CSV file to SQL Server table
Loading CSV file to database using BULK INSERT
Below are the step by step approach to easily load data from CSV file into SQL Server database table.- First create the table in the database corresponding to CSV file
CREATE TABLE NameList
(
FirstName varchar(40),
LastName varchar(40)
)
- Now, generate format file for the above table using
BCP Format
option
C:\Users\venkat>BCP master.dbo.NameList format nul
-x -S ServerName -c -f c:\dev\NameListFormat.xml -t, -T
- Now, load data into the table using
BULK INSERT
TRUNCATE TABLE dbo.NameList; -- (for testing)
BULK INSERT dbo.NameList
FROM 'c:\dev\NameList.csv'
WITH (FORMATFILE = 'C:\dev\NameListFormat.xml');
GO
- Now, data is successfully loaded from CSV to SQL Server table.
Subscribe to:
Posts (Atom)
How to Handle SSIS Database movement from one environment to another
Below are the steps to follow the movement of SSISDB from one environment to another: -- opening the existing Database master key in S...
-
We are using Azure Data Factory to load data from Azure storage blobs to SQL Server on-premises. During data loading, we faced SQL Error: ...
-
Hello World, Through this blog, I am going to ruminate over lots of technical stuff around databases. Hoping to provide quality conten...
-
Below are the steps to follow the movement of SSISDB from one environment to another: -- opening the existing Database master key in S...