Last active
April 6, 2018 14:45
-
-
Save AshFlaw/02634d520dc6900f8a9d202bd63bb8e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Test-SQLTableExists | |
{ | |
param ($Instance,$Database,$TableName) | |
$Return = $SQL = $dataTable = $null | |
$sql = "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'$TableName'" | |
$dataTable = Invoke-Sqlcmd2 -ServerInstance $Instance -Database $Database -Query $sql | |
if ($dataTable) {$return = $true} | |
else {$return = $false} | |
$Return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment