Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to hide the body of stored procedure from all other user even administrator ,how can can i do that?
SQL
create PROCEDURE [dbo].[AllCsDetails_Bilal]
	-- Add the parameters for the stored procedure here
 @FrmDate DATETIME,
 @ToDate DATETIME,
 @CsID VARCHAR(50),
 @ExporterID VARCHAR(50)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
    --IF @FrmDate IS NULL
    --BEGIN
      --SET @FrmDate = '2007/1/1'
    --END
   
    SELECT  Row_Number() Over (Order by CostSheet.csID DESC) as SNo,CostSheet.csID,
            CostSheet.RaisedBy,
            CONVERT(VARCHAR,CostSheet.csDate,106) AS csDate,
            Buyer.BuyName,
            PriceTerm.PriceTermDesc,
            CostSheet.BuyPayTerm,
            Port.PortName,
            PortFinal.PortName AS FinalDestination, 
            CostSheet.PerformaInv,
            Container.ContainerName,
            CostSheet.VIPPayableTo,
            CostSheet.CAgentName1,
            CostSheet.CAgentName2,
            CostSheet.InspectionInst,
            CostSheet.PackingInst,
            CostSheet.SpecialInst,
            CostSheet.Remarks,
            CostSheet.AppRemarks,
            CostSheet.cswStatus,
            Exporter.ExporterName,
            CostSheet.LcttInst,
            CostSheet.PurchaseTerm,
            CostSheet.PurchasePaymntTerm,
            ContractNo,
            AdditionalCharges,
            RemarksChina,
            CONVERT(VARCHAR(20),ExpDOD,106) AS ExpDOD,
            TotalTable.TotQty,
             TotLdq,
            TotalTable.TotPriceDP,
            TotalTable.TotPriceTT,
            TotalTable.TotFrieght,
            TotalTable.TotIns,
            TotalTable.TotDiscount,
            TotalTable.TotCommission1,
            TotalTable.TotCommission2, 
            TotalTable.TotVIP, 
            TotalTable.TotAdvertismentAmt, 
            TotalTable.TotDiscountPerContainer,
            TotalTable.TotNetFOB,                                
            TotalTable.TotPurchasePrice, 
            TotalTable.TotMargin,
            TotalTable.TotMarginPer,
            ItemName,SupName,
            Qty,DispatchQty,Ldq,PriceDP,PriceTT,Frieght,Ins,
            CSItemTran.Discount,Commission1,Commission2,
            VIP,AdvertismentAmt,CSItemTran.DiscountPerContainer,
            NetFOB,PurchasePrice,Margin,MarginPer
            FROM CostSheet 
            LEFT JOIN Buyer 
            ON CostSheet.BuyerID=Buyer.BuyerID 
            LEFT JOIN Port 
            ON CostSheet.PortID = Port.PortID
            LEFT JOIN PriceTerm ON 
            CostSheet.BuyPriceTerm=PriceTerm.PriceTermID 
            LEFT JOIN Container 
            ON CostSheet.ContainerID =Container.ContainerID
            LEFT JOIN Exporter
            ON CostSheet.ExporterID = Exporter.ExporterID
            LEFT JOIN Port AS PortFinal  
            ON CostSheet.FinalDestination = PortFinal.PortID
            LEFT JOIN (SELECT csID,SUM(Qty) AS TotQty,SUM(Ldq) AS TotLdq,
                                    SUM(PriceDP*Qty) AS  TotPriceDP,
                                    SUM(PriceTT*Qty) AS  TotPriceTT,
                                    SUM(Frieght*Qty) AS  TotFrieght,
                                    SUM(Ins*Qty) AS  TotIns,
                                    SUM(Discount*Qty) AS  TotDiscount,
                                    SUM(Commission1*Qty) AS  TotCommission1,
                                    SUM(Commission2*Qty) AS  TotCommission2, 
                                    SUM(VIP*Qty) AS  TotVIP, 
                                    SUM(AdvertismentAmt*Qty) AS  TotAdvertismentAmt, 
                                    SUM(DiscountPerContainer*Qty) AS  TotDiscountPerContainer,
                                    SUM(NetFOB*Qty) AS  TotNetFOB,                                
                                    SUM(PurchasePrice*Qty) AS  TotPurchasePrice, 
                                    SUM(Margin*Qty) AS  TotMargin,
                                    SUM(MarginPer*Qty) AS  TotMarginPer
                                    FROM  CSItemTran
                                    GROUP BY csID
                        ) AS TotalTable
            ON CostSheet.csID = TotalTable.csID
            LEFT JOIN  CSItemTran
            ON CostSheet.csID = CSItemTran.csID
            LEFT JOIN Item
            ON CSItemTran.ItemID = Item.ItemID
            LEFT JOIN Supplier
            ON CSItemTran.SupplierID = Supplier.SupplierID
            WHERE csDate BETWEEN @FrmDate AND @ToDate
                 AND CostSheet.csID LIKE @csID
                 AND CostSheet.ExporterID LIKE @ExporterID 
            END
Posted
Updated 20-Mar-10 6:23am
v2

1 solution

If you don't want anyone to be able to look at the stored procedure then encrypt it;

SQL
CREATE PROCEDURE AllCsDetails_Bilal
@FrmDate DATETIME,
@ToDate DATETIME,
@CsID VARCHAR(50),
@ExporterID VARCHAR(50)
WITH ENCRYPTION
AS


MSDN CREATE PROCEDURE[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900