2010-08-31 94 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