Get smo object from sql database item name

  • Hi all,

    Is there a way to get an smo object (stored proc, UDF, etc...) from an items' name and a database object?

    that is, without knowing what type of object xyz is, with the string "xyz" and a database object, can I get an smo object?

    $object = $objSrcDB.EnumObjects() | ?{$_.Name -eq $objName} gives me a System.Data.DataRow.

    If possible, I'd like to do it without getting into

    if ($Object.DatabaseObjectTypes -eq "StoredProcedure") {...}

    else if ($Object.DatabaseObjectTypes -eq "UDF") {...}


    Thanks in advance,


  • Got it:

    $object = $objSrcDB.Discover() | ?{$_.Name -eq $objName}

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply