2009-12-02 101 views
0

我存儲了proc,它會告訴我們是否有任何新的檢查要打印。現在我必須操縱數據庫表中的數據,以便至少打印一張支票。我沒有寫這個查詢。我試過了,但我至少沒有打印一張支票。誰能幫我。這裏是存儲過程SQL查詢問題,操縱數據

CREATE PROCEDURE [proc_1250_SELCashiersChecksForPrint] AS 

SELECT t_DATA_CashiersChecksIssued.ControlNbr, 
    t_DATA_CashiersChecksIssued.Audit_DateAdded, 
    t_DATA_CashiersChecksIssued.BatchNbr, 
    t_DATA_CashiersChecksIssued.SerialNbr, 
    t_DATA_CashiersChecksIssued.CheckRTN, 
    t_DATA_CashiersChecksIssued.CheckAccountNbr, 
    t_DATA_CashiersChecksIssued.Amount, 
    t_DATA_CashiersChecksIssued.DateIssued, 
    t_DATA_CashiersChecksIssued.Payee, 
    t_DATA_CashiersChecksIssued.Address, 
    t_DATA_CashiersChecksIssued.City, 
    t_DATA_CashiersChecksIssued.State, 
    t_DATA_CashiersChecksIssued.Zip, 
    t_DATA_Reclamation.ClaimId, t_DATA_Reclamation.NoticeDate, 
    t_DATA_Reclamation.FirstName, 
    t_DATA_Reclamation.MiddleName, 
    t_DATA_Reclamation.LastName, 
    t_DATA_Reclamation.ClaimTotal, 
    t_PCD_Claimant.Name AS Agency, 
    t_DATA_CashiersChecksIssued.IDENTITYCOL 
FROM t_DATA_CashiersChecksIssued INNER JOIN 
    t_DATA_Reclamation ON 
    t_DATA_CashiersChecksIssued.ControlNbr = t_DATA_Reclamation.ControlNbr 
    INNER JOIN 
    t_PCD_Claimant ON 
    t_DATA_Reclamation.ClaimantCode = t_PCD_Claimant.ClaimantCode 
WHERE (t_DATA_CashiersChecksIssued.SerialNbr IS NULL) AND 
    (t_DATA_CashiersChecksIssued.DateIssued IS NULL) 
ORDER BY t_DATA_CashiersChecksIssued.Audit_DateAdded ASC, 
t_DATA_CashiersChecksIssued.ControlNbr ASC 

GO 

`

回答

0

假設表中有數據,這將更新的第一行。

UPDATE TOP(1) t_DATA_CashiersChecksIssued 
    SET SerialMbr = NULL, 
     DataIssued = NULL 
    FROM t_DATA_CashiersChecksIssued 
INNER JOIN t_DATA_Reclamation 
    ON t_DATA_CashiersChecksIssued.ControlNbr = t_DATA_Reclamation.ControlNbr 
INNER JOIN t_PCD_Claimant 
    ON t_DATA_Reclamation.ClaimantCode = t_PCD_Claimant.ClaimantCode 
+0

我不想改變PROC。我想要操縱表格數據(比如添加額外的數據),以便得到最好的檢查結果。那麼你可以告訴我哪些表格或欄目數據需要更改以便獲得最基本的檢查結果。 – pbrp 2009-12-02 03:13:29

+0

上述SQL將操縱數據,所以存儲的proc將打印一張支票。 – 2009-12-02 03:26:51

+0

我在哪裏需要執行此查詢?我的意思是在哪個表中?我在sql企業管理器中打開了t_DATA_CashiersChecksIssued表並試圖執行那個表。但事實並非如此。 – pbrp 2009-12-02 03:34:26