Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

How to exclude replication stored procedures from a script? Expand / Collapse
Author
Message
Posted Tuesday, June 26, 2012 7:55 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 7:01 PM
Points: 7,139, Visits: 12,762
schleep (6/26/2012)
This will exclude all non-user objects. I assume they're probably not required anyway.

Get-ChildItem | where {$_.IsSystemObject -eq $false}

That brings up a good point. I have replication enabled in my DB and see the repl procs under System Stored Procedures in SSMS but when I run just Get-ChildItem (i.e. without any filtering) at the StoredProcedures prompt in PS none of the repl procs are returned, in fact no system procs are returned, I only see my user-defined stored procedures.


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1321247
Posted Tuesday, June 26, 2012 9:15 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: 2 days ago @ 5:34 AM
Points: 439, Visits: 1,014

$Srv = New-object Microsoft.SqlServer.Management.SMO.Server "Mufasa"
$Srv.Databases["Abb"].StoredProcedures | where {$_.issystemobject -eq $true} | select name

This returns 1300+ system procs -- including repls, and I don't have replication enabled.

P



Post #1321313
Posted Tuesday, June 26, 2012 9:58 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 7:01 PM
Points: 7,139, Visits: 12,762
From the OP's code, modified for my machine for demo:

Add-PSSnapin SqlServerCmdletSnapin100 -ErrorAction SilentlyContinue
Add-PSSnapin SqlServerProviderSnapin100 -ErrorAction SilentlyContinue

Set-Location SQLSERVER:\SQL\MyComputer\MyInstanceName\Databases\MyDataseName\StoredProcedures

Get-ChildItem | Select Name

I only receive a list of user-defined procs.


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1321353
Posted Tuesday, June 26, 2012 10:58 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: 2 days ago @ 5:34 AM
Points: 439, Visits: 1,014
Confirmed.

Set-Location SQLSERVER:\SQL\MyServer\Default\Databases\MyDB\StoredProcedures
dir | select name

does not return any system sprocs. I wonder why the repl sprocs would fall into the user category.

Weird...

P



Post #1321404
Posted Tuesday, June 26, 2012 11:08 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 7:01 PM
Points: 7,139, Visits: 12,762
schleep (6/26/2012)
Confirmed.

Set-Location SQLSERVER:\SQL\MyServer\Default\Databases\MyDB\StoredProcedures
dir | select name

does not return any system sprocs. I wonder why the repl sprocs would fall into the user category.

Weird...

P

Indeed. This was quite an entertaining exercise nonetheless


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1321416
Posted Tuesday, June 26, 2012 11:12 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: 2 days ago @ 5:34 AM
Points: 439, Visits: 1,014
PS: Is your picture Robert Hays in Airplane?


Post #1321422
Posted Tuesday, June 26, 2012 11:41 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 7:01 PM
Points: 7,139, Visits: 12,762
Yes, it is a picture of Robert Hays as Ted Striker. I am not sure if you can see the detail in the picture but it's from the scene when he's trying to land the plane and the sweat is pouring off him in buckets.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1321440
Posted Tuesday, June 26, 2012 11:43 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: 2 days ago @ 5:34 AM
Points: 439, Visits: 1,014
I remember it well. Hilarious!




Post #1321441
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse