Skip to content

Commit 0c048e0

Browse files
authored
Merge pull request #1 from TrilochanTripathi-01/feat/-add-check-if-file-format-is-a-sql-file
fix: added validation to check for file format
2 parents a9408f9 + e04c671 commit 0c048e0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ExecuteSqlInteractive.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ Make sure ExecuteSql.ps1 exists in the same directory
3535
. ".\RunSql.ps1"
3636

3737
$inputSqlFile = read-host "Enter the SQL file name"
38+
if (-Not ($inputSqlFile -Like "*.sql"))
39+
{
40+
Write-Host "Please enter a sql file."
41+
return
42+
}
3843
$SqlServerInstance = read-host "Enter the SqlServer Intance"
3944
$DbName = read-host "Enter the Database name"
4045
$useWindowsAuth = read-host "Do you want to use Windows Authentication, y or n?"
@@ -57,4 +62,4 @@ if($useWindowsAuth) {
5762
else
5863
{
5964
RunSql $inputSqlFile $SqluserName $Sqlpwd $DbName $SqlServerInstance $outputFile
60-
}
65+
}

0 commit comments

Comments
 (0)