how to encryp function trigger of sqlserver.

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 8 months, 3 weeks ago.

  • Author
    Posts
  • #62824

    rajesh
    Participant

    hi,

    Any documentation linke would be helpfull. i want to encrypt functions and triggers

    $db = (new-Object Microsoft.SqlServer.Management.Smo.Server("[DataBase Engine Name]")).Databases.Item("[DataBase Name]")

    Foreach ($sp in $db.StoredProcedures){
    if(!$sp.IsSystemObject){
    if (!$sp.IsEncrypted){
    $sp.TextMode = $false;
    $sp.IsEncrypted = $true;
    $sp.TextMode = $true;
    try{
    $sp.Alter();
    }catch{
    Write-Host "$sp.Name fail to encrypted."
    }
    }
    }
    }

    yours scinelrey

  • #62848

    Don Jones
    Keymaster

    You'd likely get a better answer from a SQL Server-specific forum. You're not really "using PowerShell," here, you're using SQL Server Management Objects. Consider StackExchange, or perhaps the PASS forums, to find folks who are a bit more specialized in SQL Server and SMO.

You must be logged in to reply to this topic.