I have the following stored procedure:
ALTER PROCEDURE [dbo].[sp_Detail]
@ReceiptNumber int
AS
BEGIN
SET NOCOUNT ON;
WITH invoiceT AS
(SELECT
fs_transaksie.enti AS Entity,
fs_transaksie.rek AS Account,
fs_transaksie.trans_tipe AS TransactionType,
fs_transaksie.verwysnr AS ReferenceNumber
FROM mf_history.dbo.fs_transaksie
WHERE ( fs_transaksie.verwysnr = @ReceiptNumber ) AND (fs_transaksie.trans_tipe = 3))
, transactionT as
(SELECT
fs_kwitansie.kwitansienr AS InvoiceNumber,
fs_kwitansie.ktkaart_nr AS CreditCardNumber,
fs_kwitansie.ktkaart_bank AS CCBank,
fs_kwitansie.ktkaart_bedrag AS CCAmount
FROM mf_history.dbo.fs_kwitansie
WHERE ( fs_kwitansie.kwitansienr = @ReceiptNumber )
)
select *
from invoiceT
full outer join transactionT on invoiceT.ReferenceNumber = transactionT.InvoiceNumber
END
If the fs_transaksie.trans_tipe field = 3 and fs_transaksie.rek = 5205 then an error message needs to be displayed to the user. He may NOT view the data
sp_prefix for your stored procedures. Microsoft has reserved that prefix for its own use (see Naming Stored Procedures), and you do run the risk of a name clash sometime in the future. It's also bad for your stored procedure performance. It's best to just simply avoidsp_and use something else as a prefix - or no prefix at all!