2010-08-31 99 views
0

我創建這個存儲過程錯誤的調用存儲過程

ALTER PROCEDURE [dbo].[Stock_Master_Sp] 
    @common nvarchar(1)='', 
    @PK_ID int=0, 
    @FK_StoneCategory_Master int=0, 
    @FK_StoneType_Master int=0, 
    @FK_StoneName_Master int=0, 
    @StoneSize nvarchar(50)='', 
    @StoneWeight nvarchar(50)='', 
    @FK_StoneShape_Master int=0, 
    @StoneStrange int=0, 
    @FK_StoneQuality_Master int=0, 
    @RatePerStone decimal(18, 2)=0.0, 
    @FK_User_Master int=0, 
    @QuantityInStock int=0, 
    @QuantityOnConsignment int=0, 
    @Code nvarchar(max)='' 
AS 
BEGIN 
    declare @pk int 
    declare @rate decimal(18,2) 
    declare @quantity decimal(18,2) 
IF @common='t' 
BEGIN 
    IF EXISTS (SELECT * 
    FROM Stock_Master 
    WHERE [email protected]_StoneCategory_Master AND 
    [email protected]_StoneType_Master AND 
    [email protected]_StoneName_Master AND 
    dbo.TRIM(LOWER(StoneSize))=dbo.TRIM(LOWER(@StoneSize)) AND 
    dbo.TRIM(LOWER(StoneWeight))=dbo.TRIM(LOWER(@StoneWeight)) AND 
    [email protected]_StoneShape_Master AND 
    dbo.TRIM(LOWER(StoneStrange))=dbo.TRIM(LOWER(@StoneStrange)) AND 
    [email protected]_StoneQuality_Master AND 
    dbo.TRIM(LOWER(Code))=dbo.TRIM(LOWER(@Code)) AND 
    [email protected]_User_Master) 

    BEGIN 
     SELECT @pk=PK_ID, @rate=RatePerStone, @quantity=QuantityInStock 
     FROM Stock_Master 
     WHERE [email protected]_StoneCategory_Master AND 
      [email protected]_StoneType_Master AND 
      [email protected]_StoneName_Master AND 
      dbo.TRIM(LOWER(StoneSize))=dbo.TRIM(LOWER(@StoneSize)) AND 
      dbo.TRIM(LOWER(StoneWeight))=dbo.TRIM(LOWER(@StoneWeight)) AND 
      [email protected]_StoneShape_Master AND 
      dbo.TRIM(LOWER(StoneStrange))=dbo.TRIM(LOWER(@StoneStrange)) AND 
      [email protected]_StoneQuality_Master AND 
      dbo.TRIM(LOWER(Code))=dbo.TRIM(LOWER(@Code)) AND 
      [email protected]_User_Master 

     UPDATE Stock_Master 
     SET RatePerStone = (@[email protected])/2, 
      [email protected] + @quantity 
     WHERE [email protected] 
    END 

    ELSE 
    BEGIN 
     INSERT INTO Stock_Master ([FK_StoneCategory_Master] 
      ,[FK_StoneType_Master] 
      ,[FK_StoneName_Master] 
      ,[StoneSize] 
      ,[StoneWeight] 
      ,[FK_StoneShape_Master] 
      ,[StoneStrange] 
      ,[FK_StoneQuality_Master] 
      ,[RatePerStone] 
      ,[FK_User_Master] 
      ,[QuantityInStock] 
      ,[Code]) 
     VALUES(@FK_StoneCategory_Master 
      ,@FK_StoneType_Master 
      ,@FK_StoneName_Master 
      ,dbo.TRIM(LOWER(@StoneSize)) 
      ,dbo.TRIM(LOWER(@StoneWeight)) 
      ,@FK_StoneShape_Master 
      ,@StoneStrange 
      ,@FK_StoneQuality_Master 
      ,@RatePerStone 
      ,@FK_User_Master 
      ,@QuantityInStock 
      ,dbo.TRIM(LOWER(@Code))) 

    END 

END 
END 

我打電話一樣,

Stock_Master_Sp 't','','4','4','6','2222','12','3','2','2','470','1','12','0','2112' 

,但我在打電話時

Location: memilb.cpp:1624 
Expression: pilb->m_cRef == 0 
SPID:  60 
Process ID: 1628 
Msg 3624, Level 20, State 1, Procedure Stock_Master_Sp, Line 27 
A system assertion check has failed. Check the SQL Server error log for details 
Msg 0, Level 20, State 0, Line 0 
A severe error occurred on the current command. The results, if any, should be discarded. 

得到這個錯誤有什麼解決方案請告訴我

如果我叫像比其工作

Stock_Master_Sp

Stock_Master_Sp 'T', '', '4', '4', '6', '2222', '12', '3',」 2' , '2', '470', '1', '12', '0', '2112'

+1

您是否「檢查[編輯] SQL Server錯誤日誌以獲取詳細信息」?也許你可以在這裏附加任何額外的日誌消息? – 2010-08-31 08:01:50

+1

在這個問題中發現類似的錯誤信息:http://stackoverflow.com/questions/2974917/sql-server-error(可能的解決方案:檢查你有所有的服務包安裝) – 2010-08-31 08:03:37

回答

1

爲了解決這個問題,請從你的sp中刪除lower()函數。之後會好起來的。

您可以將其視爲微軟本身的錯誤。

+0

謝謝你,但我已經解決.. .. – 2011-07-13 11:42:12