Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell - Checking existance of a sql stored procedure exists

$
0
0

Hi

I have Googled for this answer but not able to clearly find an answer. I'm not sure how to go about this but....I need to write a Powershell script to check for the existance of a specific Stored Procedure. This is to save me time in my current job when customers have issues on their Servers.

This is a script that I have written so far - I've put asterix where I don't know what to put in. Please can anyone help or give me direction please.

$serverIp="10.1.2.3"
$database="HOUSEDB"
$SqlConnection.ConnectionString = "Server=" + $serverIp + ";Database=" + $database +";Integrated Security=False;User Id=Joe123;Password=Password123"

$SqlConnection = New-Object System.Data.SqlClient.SqlConnection $SqlConnection.ConnectionString
$SqlConnection.Open()

##############################################

$sqlCommand = $SqlConnection.CreateCommand()
$sqlCommand.CommandText="************************" #SQL Select statement normally goes here

$adapter= New-Object System.Data.SqlClient.SqlDataAdapter $sqlCommand
$dataset= New-Object System.Data.DataSet

$rec=$adapter.Fill($dataset)
Write-Host ***************************


Cheers

Matt


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>